5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
12 /* Purpose: misc code */
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);
116 * Whether daytime or not
118 bool is_daytime(void)
120 s32b len = TURNS_PER_TICK * TOWN_DAWN;
121 if ((turn % len) < (len / 2))
128 * Extract day, hour, min
130 void extract_day_hour_min(int *day, int *hour, int *min)
132 s32b len = TURNS_PER_TICK * TOWN_DAWN;
133 s32b tick = turn % len + len / 4;
135 switch (p_ptr->start_race)
141 *day = (turn - (TURNS_PER_TICK * TOWN_DAWN * 3 / 4)) / len + 1;
144 *day = (turn + (TURNS_PER_TICK * TOWN_DAWN / 4)) / len + 1;
147 *hour = (24 * tick / len) % 24;
148 *min = (1440 * tick / len) % 60;
158 /* Dump 13 spaces to clear */
159 c_put_str(TERM_WHITE, " ", ROW_DAY, COL_DAY);
161 extract_day_hour_min(&day, &hour, &min);
163 /* Dump the info itself */
164 c_put_str(TERM_WHITE, format(
170 day), ROW_DAY, COL_DAY);
172 c_put_str(TERM_WHITE, format("%2d:%02d", hour, min), ROW_DAY, COL_DAY+7);
178 if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)
179 && (quest[p_ptr->inside_quest].flags & QUEST_FLAG_PRESET))
185 else if (p_ptr->wild_mode)
191 else if (p_ptr->inside_arena)
197 else if (p_ptr->inside_battle)
201 return "Monster Arena";
203 else if (!dun_level && p_ptr->town_num)
204 return town[p_ptr->town_num].name;
206 return d_name+d_info[dungeon_type].name;
212 static void prt_dungeon(void)
217 /* Dump 13 spaces to clear */
218 c_put_str(TERM_WHITE, " ", ROW_DUNGEON, COL_DUNGEON);
220 dungeon_name = map_name();
222 col = COL_DUNGEON + 6 - strlen(dungeon_name)/2;
223 if (col < 0) col = 0;
225 /* Dump the info itself */
226 c_put_str(TERM_L_UMBER, format("%s",dungeon_name),
234 * Print character stat in given row, column
236 static void prt_stat(int stat)
240 /* Display "injured" stat */
241 if (p_ptr->stat_cur[stat] < p_ptr->stat_max[stat])
243 put_str(stat_names_reduced[stat], ROW_STAT + stat, 0);
244 cnv_stat(p_ptr->stat_use[stat], tmp);
245 c_put_str(TERM_YELLOW, tmp, ROW_STAT + stat, COL_STAT + 6);
248 /* Display "healthy" stat */
251 put_str(stat_names[stat], ROW_STAT + stat, 0);
252 cnv_stat(p_ptr->stat_use[stat], tmp);
253 c_put_str(TERM_L_GREEN, tmp, ROW_STAT + stat, COL_STAT + 6);
256 /* Indicate natural maximum */
257 if (p_ptr->stat_max[stat] == p_ptr->stat_max_max[stat])
260 /* ÆüËܸì¤Ë¤«¤Ö¤é¤Ê¤¤¤è¤¦¤Ëɽ¼¨°ÌÃÖ¤òÊѹ¹ */
261 put_str("!", ROW_STAT + stat, 5);
263 put_str("!", ROW_STAT + stat, 3);
271 * Data structure for status bar
273 #define BAR_TSUYOSHI 0
274 #define BAR_HALLUCINATION 1
275 #define BAR_BLINDNESS 2
276 #define BAR_PARALYZE 3
277 #define BAR_CONFUSE 4
278 #define BAR_POISONED 5
280 #define BAR_LEVITATE 7
281 #define BAR_REFLECTION 8
282 #define BAR_PASSWALL 9
283 #define BAR_WRAITH 10
284 #define BAR_PROTEVIL 11
285 #define BAR_KAWARIMI 12
286 #define BAR_MAGICDEFENSE 13
287 #define BAR_EXPAND 14
288 #define BAR_STONESKIN 15
289 #define BAR_MULTISHADOW 16
290 #define BAR_REGMAGIC 17
291 #define BAR_ULTIMATE 18
292 #define BAR_INVULN 19
293 #define BAR_IMMACID 20
294 #define BAR_RESACID 21
295 #define BAR_IMMELEC 22
296 #define BAR_RESELEC 23
297 #define BAR_IMMFIRE 24
298 #define BAR_RESFIRE 25
299 #define BAR_IMMCOLD 26
300 #define BAR_RESCOLD 27
301 #define BAR_RESPOIS 28
302 #define BAR_RESNETH 29
303 #define BAR_RESTIME 30
304 #define BAR_DUSTROBE 31
305 #define BAR_SHFIRE 32
307 #define BAR_SHHOLY 34
308 #define BAR_EYEEYE 35
309 #define BAR_BLESSED 36
310 #define BAR_HEROISM 37
311 #define BAR_BERSERK 38
312 #define BAR_ATTKFIRE 39
313 #define BAR_ATTKCOLD 40
314 #define BAR_ATTKELEC 41
315 #define BAR_ATTKACID 42
316 #define BAR_ATTKPOIS 43
317 #define BAR_ATTKCONF 44
318 #define BAR_SENSEUNSEEN 45
319 #define BAR_TELEPATHY 46
320 #define BAR_REGENERATION 47
321 #define BAR_INFRAVISION 48
322 #define BAR_STEALTH 49
323 #define BAR_SUPERSTEALTH 50
324 #define BAR_RECALL 51
335 {TERM_YELLOW, "¤Ä", "¤Ä¤è¤·"},
336 {TERM_VIOLET, "¸¸", "¸¸³Ð"},
337 {TERM_L_DARK, "ÌÕ", "ÌÕÌÜ"},
338 {TERM_RED, "áã", "Ëãáã"},
339 {TERM_VIOLET, "Íð", "º®Íð"},
340 {TERM_GREEN, "ÆÇ", "ÆÇ"},
341 {TERM_BLUE, "¶²", "¶²ÉÝ"},
342 {TERM_L_BLUE, "Éâ", "ÉâÍ·"},
343 {TERM_SLATE, "È¿", "È¿¼Í"},
344 {TERM_SLATE, "ÊÉ", "ÊÉÈ´¤±"},
345 {TERM_L_DARK, "Í©", "Í©ÂÎ"},
346 {TERM_SLATE, "¼Ù", "ËɼÙ"},
347 {TERM_VIOLET, "ÊÑ", "ÊѤï¤ê¿È"},
348 {TERM_YELLOW, "Ëâ", "ËâË¡³»"},
349 {TERM_L_UMBER, "¿", "¿¤Ó"},
350 {TERM_WHITE, "ÀÐ", "ÀÐÈ©"},
351 {TERM_L_BLUE, "ʬ", "ʬ¿È"},
352 {TERM_SLATE, "ËÉ", "ËâË¡Ëɸæ"},
353 {TERM_YELLOW, "µæ", "µæ¶Ë"},
354 {TERM_YELLOW, "̵", "̵Ũ"},
355 {TERM_L_GREEN, "»À", "»ÀÌȱÖ"},
356 {TERM_GREEN, "»À", "ÂÑ»À"},
357 {TERM_L_BLUE, "ÅÅ", "ÅÅÌȱÖ"},
358 {TERM_BLUE, "ÅÅ", "ÂÑÅÅ"},
359 {TERM_L_RED, "²Ð", "²ÐÌȱÖ"},
360 {TERM_RED, "²Ð", "ÂѲÐ"},
361 {TERM_WHITE, "Îä", "ÎäÌȱÖ"},
362 {TERM_SLATE, "Îä", "ÂÑÎä"},
363 {TERM_GREEN, "ÆÇ", "ÂÑÆÇ"},
364 {TERM_L_DARK, "¹ö", "ÂÑÃϹö"},
365 {TERM_L_BLUE, "»þ", "ÂÑ»þ´Ö"},
366 {TERM_L_DARK, "¶À", "¶À¥ª¡¼¥é"},
367 {TERM_L_RED, "¥ª", "²Ð¥ª¡¼¥é"},
368 {TERM_WHITE, "Æ®", "Æ®µ¤"},
369 {TERM_WHITE, "À»", "À»¥ª¡¼¥é"},
370 {TERM_VIOLET, "ÌÜ", "ÌܤˤÏÌÜ"},
371 {TERM_WHITE, "½Ë", "½ËÊ¡"},
372 {TERM_WHITE, "ͦ", "ͦ"},
373 {TERM_RED, "¶¸", "¶¸Íð"},
374 {TERM_L_RED, "²Ð", "Ëâ·õ²Ð"},
375 {TERM_WHITE, "Îä", "Ëâ·õÎä"},
376 {TERM_L_BLUE, "ÅÅ", "Ëâ·õÅÅ"},
377 {TERM_SLATE, "»À", "Ëâ·õ»À"},
378 {TERM_L_GREEN, "ÆÇ", "Ëâ·õÆÇ"},
379 {TERM_RED, "Íð", "º®ÍðÂÇ·â"},
380 {TERM_L_BLUE, "»ë", "Æ©ÌÀ»ë"},
381 {TERM_ORANGE, "¥Æ", "¥Æ¥ì¥Ñ¥·"},
382 {TERM_L_BLUE, "²ó", "²óÉü"},
383 {TERM_L_RED, "ÀÖ", "ÀÖ³°"},
384 {TERM_UMBER, "±£", "±£Ì©"},
385 {TERM_YELLOW, "±£", "Ķ±£Ì©"},
386 {TERM_WHITE, "µ¢", "µ¢´Ô"},
387 {TERM_WHITE, "¸½", "¸½¼ÂÊÑÍÆ"},
392 {TERM_YELLOW, "Ts", "Tsuyoshi"},
393 {TERM_VIOLET, "Hu", "Hullc"},
394 {TERM_L_DARK, "Bl", "Blind"},
395 {TERM_RED, "Pa", "Paralyzed"},
396 {TERM_VIOLET, "Cf", "Confused"},
397 {TERM_GREEN, "Po", "Poisoned"},
398 {TERM_BLUE, "Af", "Afraid"},
399 {TERM_L_BLUE, "Lv", "Levit"},
400 {TERM_SLATE, "Rf", "Reflect"},
401 {TERM_SLATE, "Pw", "PassWall"},
402 {TERM_L_DARK, "Wr", "Wraith"},
403 {TERM_SLATE, "Ev", "PrtEvl"},
404 {TERM_VIOLET, "Kw", "Kawarimi"},
405 {TERM_YELLOW, "Md", "MgcArm"},
406 {TERM_L_UMBER, "Eh", "Expand"},
407 {TERM_WHITE, "Ss", "StnSkn"},
408 {TERM_L_BLUE, "Ms", "MltShdw"},
409 {TERM_SLATE, "Rm", "ResMag"},
410 {TERM_YELLOW, "Ul", "Ultima"},
411 {TERM_YELLOW, "Iv", "Invuln"},
412 {TERM_L_GREEN, "IAc", "ImmAcid"},
413 {TERM_GREEN, "Ac", "Acid"},
414 {TERM_L_BLUE, "IEl", "ImmElec"},
415 {TERM_BLUE, "El", "Elec"},
416 {TERM_L_RED, "IFi", "ImmFire"},
417 {TERM_RED, "Fi", "Fire"},
418 {TERM_WHITE, "ICo", "ImmCold"},
419 {TERM_SLATE, "Co", "Cold"},
420 {TERM_GREEN, "Po", "Pois"},
421 {TERM_L_DARK, "Nt", "Nthr"},
422 {TERM_L_BLUE, "Ti", "Time"},
423 {TERM_L_DARK, "Mr", "Mirr"},
424 {TERM_L_RED, "SFi", "SFire"},
425 {TERM_WHITE, "Fo", "Force"},
426 {TERM_WHITE, "Ho", "Holy"},
427 {TERM_VIOLET, "Ee", "EyeEye"},
428 {TERM_WHITE, "Bs", "Bless"},
429 {TERM_WHITE, "He", "Hero"},
430 {TERM_RED, "Br", "Berserk"},
431 {TERM_L_RED, "BFi", "BFire"},
432 {TERM_WHITE, "BCo", "BCold"},
433 {TERM_L_BLUE, "BEl", "BElec"},
434 {TERM_SLATE, "BAc", "BAcid"},
435 {TERM_L_GREEN, "BPo", "BPois"},
436 {TERM_RED, "TCf", "TchCnf"},
437 {TERM_L_BLUE, "Se", "SInv"},
438 {TERM_ORANGE, "Te", "Telepa"},
439 {TERM_L_BLUE, "Rg", "Regen"},
440 {TERM_L_RED, "If", "Infr"},
441 {TERM_UMBER, "Sl", "Stealth"},
442 {TERM_YELLOW, "Stlt", "Stealth"},
443 {TERM_WHITE, "Rc", "Recall"},
444 {TERM_WHITE, "Al", "Alter"},
449 #define ADD_FLG(FLG) (bar_flags[FLG / 32] |= (1L << (FLG % 32)))
450 #define IS_FLG(FLG) (bar_flags[FLG / 32] & (1L << (FLG % 32)))
456 static void prt_status(void)
459 int wid, hgt, row_statbar, max_col_statbar;
460 int i, col = 0, num = 0;
463 Term_get_size(&wid, &hgt);
464 row_statbar = hgt + ROW_STATBAR;
465 max_col_statbar = wid + MAX_COL_STATBAR;
467 Term_erase(0, row_statbar, max_col_statbar);
469 bar_flags[0] = bar_flags[1] = 0L;
472 if (p_ptr->tsuyoshi) ADD_FLG(BAR_TSUYOSHI);
475 if (p_ptr->image) ADD_FLG(BAR_HALLUCINATION);
478 if (p_ptr->blind) ADD_FLG(BAR_BLINDNESS);
481 if (p_ptr->paralyzed) ADD_FLG(BAR_PARALYZE);
484 if (p_ptr->confused) ADD_FLG(BAR_CONFUSE);
487 if (p_ptr->poisoned) ADD_FLG(BAR_POISONED);
489 /* Times see-invisible */
490 if (p_ptr->tim_invis) ADD_FLG(BAR_SENSEUNSEEN);
493 if (IS_TIM_ESP()) ADD_FLG(BAR_TELEPATHY);
495 /* Timed regenerate */
496 if (p_ptr->tim_regen) ADD_FLG(BAR_REGENERATION);
498 /* Timed infra-vision */
499 if (p_ptr->tim_infra) ADD_FLG(BAR_INFRAVISION);
501 /* Protection from evil */
502 if (p_ptr->protevil) ADD_FLG(BAR_PROTEVIL);
504 /* Invulnerability */
505 if (IS_INVULN()) ADD_FLG(BAR_INVULN);
508 if (p_ptr->wraith_form) ADD_FLG(BAR_WRAITH);
511 if (p_ptr->kabenuke) ADD_FLG(BAR_PASSWALL);
513 if (p_ptr->tim_reflect) ADD_FLG(BAR_REFLECTION);
516 if (IS_HERO()) ADD_FLG(BAR_HEROISM);
518 /* Super Heroism / berserk */
519 if (p_ptr->shero) ADD_FLG(BAR_BERSERK);
522 if (IS_BLESSED()) ADD_FLG(BAR_BLESSED);
525 if (p_ptr->magicdef) ADD_FLG(BAR_MAGICDEFENSE);
527 if (p_ptr->tsubureru) ADD_FLG(BAR_EXPAND);
529 if (p_ptr->shield) ADD_FLG(BAR_STONESKIN);
531 if (p_ptr->special_defense & NINJA_KAWARIMI) ADD_FLG(BAR_KAWARIMI);
534 if (p_ptr->special_defense & DEFENSE_ACID) ADD_FLG(BAR_IMMACID);
535 if (IS_OPPOSE_ACID()) ADD_FLG(BAR_RESACID);
537 /* Oppose Lightning */
538 if (p_ptr->special_defense & DEFENSE_ELEC) ADD_FLG(BAR_IMMELEC);
539 if (IS_OPPOSE_ELEC()) ADD_FLG(BAR_RESELEC);
542 if (p_ptr->special_defense & DEFENSE_FIRE) ADD_FLG(BAR_IMMFIRE);
543 if (IS_OPPOSE_FIRE()) ADD_FLG(BAR_RESFIRE);
546 if (p_ptr->special_defense & DEFENSE_COLD) ADD_FLG(BAR_IMMCOLD);
547 if (IS_OPPOSE_COLD()) ADD_FLG(BAR_RESCOLD);
550 if (IS_OPPOSE_POIS()) ADD_FLG(BAR_RESPOIS);
553 if (p_ptr->word_recall) ADD_FLG(BAR_RECALL);
556 if (p_ptr->alter_reality) ADD_FLG(BAR_ALTER);
559 if (p_ptr->afraid) ADD_FLG(BAR_AFRAID);
562 if (p_ptr->tim_res_time) ADD_FLG(BAR_RESTIME);
564 if (p_ptr->multishadow) ADD_FLG(BAR_MULTISHADOW);
566 /* Confusing Hands */
567 if (p_ptr->special_attack & ATTACK_CONFUSE) ADD_FLG(BAR_ATTKCONF);
569 if (p_ptr->resist_magic) ADD_FLG(BAR_REGMAGIC);
571 /* Ultimate-resistance */
572 if (p_ptr->ult_res) ADD_FLG(BAR_ULTIMATE);
575 if (p_ptr->tim_ffall) ADD_FLG(BAR_LEVITATE);
577 if (p_ptr->tim_res_nether) ADD_FLG(BAR_RESNETH);
579 if (p_ptr->dustrobe) ADD_FLG(BAR_DUSTROBE);
582 if (p_ptr->special_attack & ATTACK_FIRE) ADD_FLG(BAR_ATTKFIRE);
583 if (p_ptr->special_attack & ATTACK_COLD) ADD_FLG(BAR_ATTKCOLD);
584 if (p_ptr->special_attack & ATTACK_ELEC) ADD_FLG(BAR_ATTKELEC);
585 if (p_ptr->special_attack & ATTACK_ACID) ADD_FLG(BAR_ATTKACID);
586 if (p_ptr->special_attack & ATTACK_POIS) ADD_FLG(BAR_ATTKPOIS);
587 if (p_ptr->special_defense & NINJA_S_STEALTH) ADD_FLG(BAR_SUPERSTEALTH);
589 if (p_ptr->tim_sh_fire) ADD_FLG(BAR_SHFIRE);
592 if (IS_TIM_STEALTH()) ADD_FLG(BAR_STEALTH);
594 if (p_ptr->tim_sh_touki) ADD_FLG(BAR_TOUKI);
597 if (p_ptr->tim_sh_holy) ADD_FLG(BAR_SHHOLY);
599 /* An Eye for an Eye */
600 if (p_ptr->tim_eyeeye) ADD_FLG(BAR_EYEEYE);
602 /* Calcurate length */
603 for (i = 0; bar[i].sstr; i++)
607 col += strlen(bar[i].lstr) + 1;
612 /* If there are not excess spaces for long strings, use short one */
613 if (col - 1 > max_col_statbar)
618 for (i = 0; bar[i].sstr; i++)
622 col += strlen(bar[i].sstr);
626 /* If there are excess spaces for short string, use more */
627 if (col - 1 <= max_col_statbar - (num-1))
635 /* Centering display column */
636 col = (max_col_statbar - col) / 2;
638 /* Display status bar */
639 for (i = 0; bar[i].sstr; i++)
644 if (space == 2) str = bar[i].lstr;
645 else str = bar[i].sstr;
647 c_put_str(bar[i].attr, str, row_statbar, col);
649 if (space > 0) col++;
650 if (col > max_col_statbar) break;
658 * Prints "title", including "wizard" or "winner" as needed.
660 static void prt_title(void)
669 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
678 else if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
680 if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
683 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
692 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½ ¾Î¹æ */
703 my_strcpy(str, player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5], sizeof(str));
707 prt_field(p, ROW_TITLE, COL_TITLE);
714 static void prt_level(void)
719 sprintf(tmp, "%5d", p_ptr->lev);
721 sprintf(tmp, "%6d", p_ptr->lev);
725 if (p_ptr->lev >= p_ptr->max_plv)
728 put_str("¥ì¥Ù¥ë ", ROW_LEVEL, 0);
729 c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 7);
731 put_str("LEVEL ", ROW_LEVEL, 0);
732 c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 6);
739 put_str("x¥ì¥Ù¥ë", ROW_LEVEL, 0);
740 c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 7);
742 put_str("Level ", ROW_LEVEL, 0);
743 c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 6);
751 * Display the experience
753 static void prt_exp(void)
757 if ((!exp_need)||(p_ptr->prace == RACE_ANDROID))
760 (void)sprintf(out_val, "%7ld", (long)p_ptr->exp);
762 (void)sprintf(out_val, "%8ld", (long)p_ptr->exp);
767 if (p_ptr->lev >= PY_MAX_LEVEL)
769 (void)sprintf(out_val, "********");
774 (void)sprintf(out_val, "%7ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp);
776 (void)sprintf(out_val, "%8ld", (long)(player_exp [p_ptr->lev - 1] * p_ptr->expfact / 100L) - p_ptr->exp);
781 if (p_ptr->exp >= p_ptr->max_exp)
784 if (p_ptr->prace == RACE_ANDROID) put_str("¶¯²½ ", ROW_EXP, 0);
785 else put_str("·Ð¸³ ", ROW_EXP, 0);
786 c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 5);
788 if (p_ptr->prace == RACE_ANDROID) put_str("Cst ", ROW_EXP, 0);
789 else put_str("EXP ", ROW_EXP, 0);
790 c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 4);
797 put_str("x·Ð¸³", ROW_EXP, 0);
798 c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 5);
800 put_str("Exp ", ROW_EXP, 0);
801 c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 4);
808 * Prints current gold
810 static void prt_gold(void)
815 put_str("¡ð ", ROW_GOLD, COL_GOLD);
817 put_str("AU ", ROW_GOLD, COL_GOLD);
820 sprintf(tmp, "%9ld", (long)p_ptr->au);
821 c_put_str(TERM_L_GREEN, tmp, ROW_GOLD, COL_GOLD + 3);
829 static void prt_ac(void)
834 /* AC ¤Îɽ¼¨Êý¼°¤òÊѹ¹¤·¤Æ¤¤¤ë */
835 put_str(" £Á£Ã( )", ROW_AC, COL_AC);
836 sprintf(tmp, "%5d", p_ptr->dis_ac + p_ptr->dis_to_a);
837 c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 6);
839 put_str("Cur AC ", ROW_AC, COL_AC);
840 sprintf(tmp, "%5d", p_ptr->dis_ac + p_ptr->dis_to_a);
841 c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 7);
848 * Prints Cur/Max hit points
850 static void prt_hp(void)
852 /* ¥Ò¥Ã¥È¥Ý¥¤¥ó¥È¤Îɽ¼¨ÊýË¡¤òÊѹ¹ */
858 /* put_str(" £È£Ð¡¦£Í£Ð", ROW_HPMP, COL_HPMP); */
860 put_str("HP", ROW_CURHP, COL_CURHP);
862 /* ¸½ºß¤Î¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */
863 sprintf(tmp, "%4d", p_ptr->chp);
865 if (p_ptr->chp >= p_ptr->mhp)
867 color = TERM_L_GREEN;
869 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
878 c_put_str(color, tmp, ROW_CURHP, COL_CURHP+3);
881 put_str( "/", ROW_CURHP, COL_CURHP + 7 );
883 /* ºÇÂç¥Ò¥Ã¥È¥Ý¥¤¥ó¥È */
884 sprintf(tmp, "%4d", p_ptr->mhp);
885 color = TERM_L_GREEN;
887 c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 8 );
892 * Prints players max/cur spell points
894 static void prt_sp(void)
896 /* ¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È¤Îɽ¼¨ÊýË¡¤òÊѹ¹¤·¤Æ¤¤¤ë */
901 /* Do not show mana unless it matters */
902 if (!mp_ptr->spell_book) return;
905 /* put_str(" £Í£Ð / ºÇÂç", ROW_MAXSP, COL_MAXSP); */
908 put_str("MP", ROW_CURSP, COL_CURSP);
910 put_str("SP", ROW_CURSP, COL_CURSP);
913 /* ¸½ºß¤Î¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */
914 sprintf(tmp, "%4d", p_ptr->csp);
916 if (p_ptr->csp >= p_ptr->msp)
918 color = TERM_L_GREEN;
920 else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
929 c_put_str(color, tmp, ROW_CURSP, COL_CURSP+3);
932 put_str( "/", ROW_CURSP, COL_CURSP + 7 );
934 /* ºÇÂç¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È */
935 sprintf(tmp, "%4d", p_ptr->msp);
936 color = TERM_L_GREEN;
938 c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 8);
943 * Prints depth in stat area
945 static void prt_depth(void)
948 int wid, hgt, row_depth, col_depth;
949 byte attr = TERM_WHITE;
951 Term_get_size(&wid, &hgt);
952 col_depth = wid + COL_DEPTH;
953 row_depth = hgt + ROW_DEPTH;
958 strcpy(depths, "ÃϾå");
960 strcpy(depths, "Surf.");
963 else if (p_ptr->inside_quest && !dungeon_type)
966 strcpy(depths, "ÃϾå");
968 strcpy(depths, "Quest");
974 if (depth_in_feet) (void)sprintf(depths, "%d ft", dun_level * 50);
975 else (void)sprintf(depths, "%d ³¬", dun_level);
977 if (depth_in_feet) (void)sprintf(depths, "%d ft", dun_level * 50);
978 else (void)sprintf(depths, "Lev %d", dun_level);
983 /* Get color of level based on feeling -JSV- */
984 if ((turn - old_turn >= (150 - dun_level) * TURNS_PER_TICK) || cheat_xtra)
988 case 1: attr = TERM_L_BLUE; break; /* Special */
989 case 2: attr = TERM_VIOLET; break; /* Horrible visions */
990 case 3: attr = TERM_RED; break; /* Very dangerous */
991 case 4: attr = TERM_L_RED; break; /* Very bad feeling */
992 case 5: attr = TERM_ORANGE; break; /* Bad feeling */
993 case 6: attr = TERM_YELLOW; break; /* Nervous */
994 case 7: attr = TERM_L_UMBER; break; /* Luck is turning */
995 case 8: attr = TERM_L_WHITE; break; /* Don't like */
996 case 9: attr = TERM_WHITE; break; /* Reasonably safe */
997 case 10: attr = TERM_WHITE; break; /* Boring place */
1002 /* Right-Adjust the "depth", and clear old values */
1003 c_prt(attr, format("%7s", depths), row_depth, col_depth);
1008 * Prints status of hunger
1010 static void prt_hunger(void)
1012 /* Fainting / Starving */
1013 if (p_ptr->food < PY_FOOD_FAINT)
1016 c_put_str(TERM_RED, "¿ê¼å ", ROW_HUNGRY, COL_HUNGRY);
1018 c_put_str(TERM_RED, "Weak ", ROW_HUNGRY, COL_HUNGRY);
1024 else if (p_ptr->food < PY_FOOD_WEAK)
1027 c_put_str(TERM_ORANGE, "¿ê¼å ", ROW_HUNGRY, COL_HUNGRY);
1029 c_put_str(TERM_ORANGE, "Weak ", ROW_HUNGRY, COL_HUNGRY);
1035 else if (p_ptr->food < PY_FOOD_ALERT)
1038 c_put_str(TERM_YELLOW, "¶õÊ¢ ", ROW_HUNGRY, COL_HUNGRY);
1040 c_put_str(TERM_YELLOW, "Hungry", ROW_HUNGRY, COL_HUNGRY);
1046 else if (p_ptr->food < PY_FOOD_FULL)
1048 c_put_str(TERM_L_GREEN, " ", ROW_HUNGRY, COL_HUNGRY);
1052 else if (p_ptr->food < PY_FOOD_MAX)
1055 c_put_str(TERM_L_GREEN, "ËþÊ¢ ", ROW_HUNGRY, COL_HUNGRY);
1057 c_put_str(TERM_L_GREEN, "Full ", ROW_HUNGRY, COL_HUNGRY);
1066 c_put_str(TERM_GREEN, "¿©²á¤®", ROW_HUNGRY, COL_HUNGRY);
1068 c_put_str(TERM_GREEN, "Gorged", ROW_HUNGRY, COL_HUNGRY);
1076 * Prints Searching, Resting, Paralysis, or 'count' status
1077 * Display is always exactly 10 characters wide (see below)
1079 * This function was a major bottleneck when resting, so a lot of
1080 * the text formatting code was optimized in place below.
1082 static void prt_state(void)
1084 byte attr = TERM_WHITE;
1091 if (command_rep > 999)
1094 sprintf(text, "%2d00", command_rep / 100);
1096 (void)sprintf(text, "%2d00", command_rep / 100);
1103 sprintf(text, " %2d", command_rep);
1105 (void)sprintf(text, " %2d", command_rep);
1114 switch(p_ptr->action)
1119 strcpy(text, "õº÷");
1121 strcpy(text, "Sear");
1129 /* Start with "Rest" */
1137 /* Extensive (timed) rest */
1138 if (resting >= 1000)
1143 text[1] = '0' + (i % 10);
1144 text[0] = '0' + (i / 10);
1147 /* Long (timed) rest */
1148 else if (resting >= 100)
1151 text[3] = '0' + (i % 10);
1153 text[2] = '0' + (i % 10);
1154 text[1] = '0' + (i / 10);
1157 /* Medium (timed) rest */
1158 else if (resting >= 10)
1161 text[3] = '0' + (i % 10);
1162 text[2] = '0' + (i / 10);
1165 /* Short (timed) rest */
1166 else if (resting > 0)
1169 text[3] = '0' + (i);
1172 /* Rest until healed */
1173 else if (resting == -1)
1175 text[0] = text[1] = text[2] = text[3] = '*';
1178 /* Rest until done */
1179 else if (resting == -2)
1181 text[0] = text[1] = text[2] = text[3] = '&';
1188 strcpy(text, "³Ø½¬");
1190 strcpy(text, "lear");
1192 if (new_mane) attr = TERM_L_RED;
1198 strcpy(text, "Äà¤ê");
1200 strcpy(text, "fish");
1207 for (i = 0; i < MAX_KAMAE; i++)
1208 if (p_ptr->special_defense & (KAMAE_GENBU << i)) break;
1211 case 0: attr = TERM_GREEN;break;
1212 case 1: attr = TERM_WHITE;break;
1213 case 2: attr = TERM_L_BLUE;break;
1214 case 3: attr = TERM_L_RED;break;
1216 strcpy(text, kamae_shurui[i].desc);
1222 for (i = 0; i < MAX_KATA; i++)
1223 if (p_ptr->special_defense & (KATA_IAI << i)) break;
1224 strcpy(text, kata_shurui[i].desc);
1230 strcpy(text, "²Î ");
1232 strcpy(text, "Sing");
1236 case ACTION_HAYAGAKE:
1239 strcpy(text, "®¶î");
1241 strcpy(text, "Fast");
1253 /* Display the info (or blanks) */
1254 c_put_str(attr, format("%5.5s",text), ROW_STATE, COL_STATE);
1259 * Prints the speed of a character. -CJS-
1261 static void prt_speed(void)
1263 int i = p_ptr->pspeed;
1264 bool is_fast = IS_FAST();
1266 byte attr = TERM_WHITE;
1268 int wid, hgt, row_speed, col_speed;
1270 Term_get_size(&wid, &hgt);
1271 col_speed = wid + COL_SPEED;
1272 row_speed = hgt + ROW_SPEED;
1274 /* Hack -- Visually "undo" the Search Mode Slowdown */
1275 if (p_ptr->action == ACTION_SEARCH) i += 10;
1282 if (m_list[p_ptr->riding].fast && !m_list[p_ptr->riding].slow) attr = TERM_L_BLUE;
1283 else if (m_list[p_ptr->riding].slow && !m_list[p_ptr->riding].fast) attr = TERM_VIOLET;
1284 else attr = TERM_GREEN;
1286 else if ((is_fast && !p_ptr->slow) || p_ptr->lightspeed) attr = TERM_YELLOW;
1287 else if (p_ptr->slow && !is_fast) attr = TERM_VIOLET;
1288 else attr = TERM_L_GREEN;
1290 sprintf(buf, "%s(+%d)", (p_ptr->riding ? "¾èÇÏ" : "²Ã®"), (i - 110));
1292 sprintf(buf, "Fast(+%d)", (i - 110));
1302 if (m_list[p_ptr->riding].fast && !m_list[p_ptr->riding].slow) attr = TERM_L_BLUE;
1303 else if (m_list[p_ptr->riding].slow && !m_list[p_ptr->riding].fast) attr = TERM_VIOLET;
1304 else attr = TERM_RED;
1306 else if (is_fast && !p_ptr->slow) attr = TERM_YELLOW;
1307 else if (p_ptr->slow && !is_fast) attr = TERM_VIOLET;
1308 else attr = TERM_L_UMBER;
1310 sprintf(buf, "%s(-%d)", (p_ptr->riding ? "¾èÇÏ" : "¸ºÂ®"), (110 - i));
1312 sprintf(buf, "Slow(-%d)", (110 - i));
1315 else if (p_ptr->riding)
1319 strcpy(buf, "¾èÇÏÃæ");
1321 strcpy(buf, "Riding");
1325 /* Display the speed */
1326 c_put_str(attr, format("%-9s", buf), row_speed, col_speed);
1330 static void prt_study(void)
1332 int wid, hgt, row_study, col_study;
1334 Term_get_size(&wid, &hgt);
1335 col_study = wid + COL_STUDY;
1336 row_study = hgt + ROW_STUDY;
1338 if (p_ptr->new_spells)
1341 put_str("³Ø½¬", row_study, col_study);
1343 put_str("Stud", row_study, col_study);
1349 put_str(" ", row_study, col_study);
1354 static void prt_mane(void)
1356 int wid, hgt, row_study, col_study;
1358 Term_get_size(&wid, &hgt);
1359 col_study = wid + COL_STUDY;
1360 row_study = hgt + ROW_STUDY;
1362 if (p_ptr->pclass == CLASS_IMITATOR)
1364 if (p_ptr->mane_num)
1367 if (new_mane) attr = TERM_L_RED;
1368 else attr = TERM_WHITE;
1370 c_put_str(attr, "¤Þ¤Í", row_study, col_study);
1372 c_put_str(attr, "Mane", row_study, col_study);
1377 put_str(" ", row_study, col_study);
1383 static void prt_cut(void)
1390 c_put_str(TERM_L_RED, "Ã×Ì¿½ý ", ROW_CUT, COL_CUT);
1392 c_put_str(TERM_L_RED, "Mortal wound", ROW_CUT, COL_CUT);
1399 c_put_str(TERM_RED, "¤Ò¤É¤¤¿¼¼ê ", ROW_CUT, COL_CUT);
1401 c_put_str(TERM_RED, "Deep gash ", ROW_CUT, COL_CUT);
1408 c_put_str(TERM_RED, "½Å½ý ", ROW_CUT, COL_CUT);
1410 c_put_str(TERM_RED, "Severe cut ", ROW_CUT, COL_CUT);
1417 c_put_str(TERM_ORANGE, "ÂçÊѤʽý ", ROW_CUT, COL_CUT);
1419 c_put_str(TERM_ORANGE, "Nasty cut ", ROW_CUT, COL_CUT);
1426 c_put_str(TERM_ORANGE, "¤Ò¤É¤¤½ý ", ROW_CUT, COL_CUT);
1428 c_put_str(TERM_ORANGE, "Bad cut ", ROW_CUT, COL_CUT);
1435 c_put_str(TERM_YELLOW, "·Ú½ý ", ROW_CUT, COL_CUT);
1437 c_put_str(TERM_YELLOW, "Light cut ", ROW_CUT, COL_CUT);
1444 c_put_str(TERM_YELLOW, "¤«¤¹¤ê½ý ", ROW_CUT, COL_CUT);
1446 c_put_str(TERM_YELLOW, "Graze ", ROW_CUT, COL_CUT);
1452 put_str(" ", ROW_CUT, COL_CUT);
1458 static void prt_stun(void)
1460 int s = p_ptr->stun;
1465 c_put_str(TERM_RED, "°Õ¼±ÉÔÌÀÎÆ ", ROW_STUN, COL_STUN);
1467 c_put_str(TERM_RED, "Knocked out ", ROW_STUN, COL_STUN);
1474 c_put_str(TERM_ORANGE, "¤Ò¤É¤¯Û¯Û° ", ROW_STUN, COL_STUN);
1476 c_put_str(TERM_ORANGE, "Heavy stun ", ROW_STUN, COL_STUN);
1483 c_put_str(TERM_ORANGE, "ۯ۰ ", ROW_STUN, COL_STUN);
1485 c_put_str(TERM_ORANGE, "Stun ", ROW_STUN, COL_STUN);
1491 put_str(" ", ROW_STUN, COL_STUN);
1498 * Redraw the "monster health bar" -DRS-
1499 * Rather extensive modifications by -BEN-
1501 * The "monster health bar" provides visual feedback on the "health"
1502 * of the monster currently being "tracked". There are several ways
1503 * to "track" a monster, including targetting it, attacking it, and
1504 * affecting it (and nobody else) with a ranged attack.
1506 * Display the monster health bar (affectionately known as the
1507 * "health-o-meter"). Clear health bar if nothing is being tracked.
1508 * Auto-track current target monster when bored. Note that the
1509 * health-bar stops tracking any monster that "disappears".
1511 static void health_redraw(bool riding)
1515 monster_type *m_ptr;
1519 health_who = p_ptr->riding;
1520 row = ROW_RIDING_INFO;
1521 col = COL_RIDING_INFO;
1525 health_who = p_ptr->health_who;
1530 m_ptr = &m_list[health_who];
1535 /* Erase the health bar */
1536 Term_erase(col, row, 12);
1539 /* Tracking an unseen monster */
1540 else if (!m_ptr->ml)
1542 /* Indicate that the monster health is "unknown" */
1543 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1546 /* Tracking a hallucinatory monster */
1547 else if (p_ptr->image)
1549 /* Indicate that the monster health is "unknown" */
1550 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1553 /* Tracking a dead monster (???) */
1554 else if (m_ptr->hp < 0)
1556 /* Indicate that the monster health is "unknown" */
1557 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1560 /* Tracking a visible monster */
1563 /* Extract the "percent" of health */
1564 int pct = 100L * m_ptr->hp / m_ptr->maxhp;
1565 int pct2 = 100L * m_ptr->hp / m_ptr->max_maxhp;
1567 /* Convert percent into "health" */
1568 int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
1570 /* Default to almost dead */
1571 byte attr = TERM_RED;
1574 if (m_ptr->invulner) attr = TERM_WHITE;
1577 else if (m_ptr->csleep) attr = TERM_BLUE;
1580 else if (m_ptr->monfear) attr = TERM_VIOLET;
1583 else if (pct >= 100) attr = TERM_L_GREEN;
1585 /* Somewhat Wounded */
1586 else if (pct >= 60) attr = TERM_YELLOW;
1589 else if (pct >= 25) attr = TERM_ORANGE;
1592 else if (pct >= 10) attr = TERM_L_RED;
1594 /* Default to "unknown" */
1595 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1597 /* Dump the current "health" (use '*' symbols) */
1598 Term_putstr(col + 1, row, len, attr, "**********");
1605 * Display basic info (mostly left of map)
1607 static void prt_frame_basic(void)
1611 /* Race and Class */
1612 if (p_ptr->mimic_form)
1613 prt_field(mimic_info[p_ptr->mimic_form].title, ROW_RACE, COL_RACE);
1617 my_strcpy(str, rp_ptr->title, sizeof(str));
1618 prt_field(str, ROW_RACE, COL_RACE);
1620 /* prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
1621 /* prt_field(ap_ptr->title, ROW_SEIKAKU, COL_SEIKAKU); */
1627 /* Level/Experience */
1632 for (i = 0; i < 6; i++) prt_stat(i);
1650 health_redraw(FALSE);
1651 health_redraw(TRUE);
1656 * Display extra info (mostly below map)
1658 static void prt_frame_extra(void)
1683 * Hack -- display inventory in sub-windows
1685 static void fix_inven(void)
1690 for (j = 0; j < 8; j++)
1695 if (!angband_term[j]) continue;
1697 /* No relevant flags */
1698 if (!(window_flag[j] & (PW_INVEN))) continue;
1701 Term_activate(angband_term[j]);
1703 /* Display inventory */
1717 * Hack -- display equipment in sub-windows
1719 static void fix_equip(void)
1724 for (j = 0; j < 8; j++)
1729 if (!angband_term[j]) continue;
1731 /* No relevant flags */
1732 if (!(window_flag[j] & (PW_EQUIP))) continue;
1735 Term_activate(angband_term[j]);
1737 /* Display equipment */
1750 * Hack -- display equipment in sub-windows
1752 static void fix_spell(void)
1757 for (j = 0; j < 8; j++)
1762 if (!angband_term[j]) continue;
1764 /* No relevant flags */
1765 if (!(window_flag[j] & (PW_SPELL))) continue;
1768 Term_activate(angband_term[j]);
1770 /* Display spell list */
1771 display_spell_list();
1783 * Hack -- display character in sub-windows
1785 static void fix_player(void)
1790 for (j = 0; j < 8; j++)
1795 if (!angband_term[j]) continue;
1797 /* No relevant flags */
1798 if (!(window_flag[j] & (PW_PLAYER))) continue;
1801 Term_activate(angband_term[j]);
1805 /* Display player */
1819 * Hack -- display recent messages in sub-windows
1821 * XXX XXX XXX Adjust for width and split messages
1823 static void fix_message(void)
1830 for (j = 0; j < 8; j++)
1835 if (!angband_term[j]) continue;
1837 /* No relevant flags */
1838 if (!(window_flag[j] & (PW_MESSAGE))) continue;
1841 Term_activate(angband_term[j]);
1844 Term_get_size(&w, &h);
1847 for (i = 0; i < h; i++)
1849 /* Dump the message on the appropriate line */
1850 Term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((s16b)i));
1853 Term_locate(&x, &y);
1855 /* Clear to end of line */
1856 Term_erase(x, y, 255);
1869 * Hack -- display overhead view in sub-windows
1871 * Note that the "player" symbol does NOT appear on the map.
1873 static void fix_overhead(void)
1880 for (j = 0; j < 8; j++)
1886 if (!angband_term[j]) continue;
1888 /* No relevant flags */
1889 if (!(window_flag[j] & (PW_OVERHEAD))) continue;
1892 Term_activate(angband_term[j]);
1894 /* Full map in too small window is useless */
1895 Term_get_size(&wid, &hgt);
1896 if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2)
1899 display_map(&cy, &cx);
1912 * Hack -- display dungeon view in sub-windows
1914 static void fix_dungeon(void)
1919 for (j = 0; j < 8; j++)
1924 if (!angband_term[j]) continue;
1926 /* No relevant flags */
1927 if (!(window_flag[j] & (PW_DUNGEON))) continue;
1930 Term_activate(angband_term[j]);
1932 /* Redraw dungeon view */
1945 * Hack -- display monster recall in sub-windows
1947 static void fix_monster(void)
1952 for (j = 0; j < 8; j++)
1957 if (!angband_term[j]) continue;
1959 /* No relevant flags */
1960 if (!(window_flag[j] & (PW_MONSTER))) continue;
1963 Term_activate(angband_term[j]);
1965 /* Display monster race info */
1966 if (p_ptr->monster_race_idx) display_roff(p_ptr->monster_race_idx);
1978 * Hack -- display object recall in sub-windows
1980 static void fix_object(void)
1985 for (j = 0; j < 8; j++)
1990 if (!angband_term[j]) continue;
1992 /* No relevant flags */
1993 if (!(window_flag[j] & (PW_OBJECT))) continue;
1996 Term_activate(angband_term[j]);
1998 /* Display monster race info */
1999 if (p_ptr->object_kind_idx) display_koff(p_ptr->object_kind_idx);
2011 * Calculate number of spells player should have, and forget,
2012 * or remember, spells until that number is properly reflected.
2014 * Note that this function induces various "status" messages,
2015 * which must be bypasses until the character is created.
2017 static void calc_spells(void)
2019 int i, j, k, levels;
2021 int num_boukyaku = 0;
2030 /* Hack -- must be literate */
2031 if (!mp_ptr->spell_book) return;
2033 /* Hack -- wait for creation */
2034 if (!character_generated) return;
2036 /* Hack -- handle "xtra" mode */
2037 if (character_xtra) return;
2039 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
2041 p_ptr->new_spells = 0;
2045 p = spell_category_name(mp_ptr->spell_book);
2047 /* Determine the number of spells allowed */
2048 levels = p_ptr->lev - mp_ptr->spell_first + 1;
2050 /* Hack -- no negative spells */
2051 if (levels < 0) levels = 0;
2053 /* Extract total allowed spells */
2054 num_allowed = (adj_mag_study[p_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
2056 if ((p_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
2060 if (p_ptr->pclass == CLASS_SAMURAI)
2064 else if (p_ptr->realm2 == REALM_NONE)
2066 num_allowed = (num_allowed+1)/2;
2067 if (num_allowed>(32+bonus)) num_allowed = 32+bonus;
2069 else if ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))
2071 if (num_allowed>(96+bonus)) num_allowed = 96+bonus;
2075 if (num_allowed>(80+bonus)) num_allowed = 80+bonus;
2078 /* Count the number of spells we know */
2079 for (j = 0; j < 64; j++)
2081 /* Count known spells */
2083 (p_ptr->spell_forgotten1 & (1L << j)) :
2084 (p_ptr->spell_forgotten2 & (1L << (j - 32))))
2090 /* See how many spells we must forget or may learn */
2091 p_ptr->new_spells = num_allowed + p_ptr->add_spells + num_boukyaku - p_ptr->learned_spells;
2093 /* Forget spells which are too hard */
2094 for (i = 63; i >= 0; i--)
2096 /* Efficiency -- all done */
2097 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
2099 /* Access the spell */
2100 j = p_ptr->spell_order[i];
2102 /* Skip non-spells */
2103 if (j >= 99) continue;
2107 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
2110 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
2112 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
2115 s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
2117 s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
2119 /* Skip spells we are allowed to know */
2120 if (s_ptr->slevel <= p_ptr->lev) continue;
2124 (p_ptr->spell_learned1 & (1L << j)) :
2125 (p_ptr->spell_learned2 & (1L << (j - 32))))
2127 /* Mark as forgotten */
2130 p_ptr->spell_forgotten1 |= (1L << j);
2131 which = p_ptr->realm1;
2135 p_ptr->spell_forgotten2 |= (1L << (j - 32));
2136 which = p_ptr->realm2;
2139 /* No longer known */
2142 p_ptr->spell_learned1 &= ~(1L << j);
2143 which = p_ptr->realm1;
2147 p_ptr->spell_learned2 &= ~(1L << (j - 32));
2148 which = p_ptr->realm2;
2153 msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
2154 spell_names[technic2magic(which)-1][j%32], p );
2156 msg_format("You have forgotten the %s of %s.", p,
2157 spell_names[technic2magic(which)-1][j%32]);
2161 /* One more can be learned */
2162 p_ptr->new_spells++;
2167 /* Forget spells if we know too many spells */
2168 for (i = 63; i >= 0; i--)
2170 /* Stop when possible */
2171 if (p_ptr->new_spells >= 0) break;
2173 /* Efficiency -- all done */
2174 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
2176 /* Get the (i+1)th spell learned */
2177 j = p_ptr->spell_order[i];
2179 /* Skip unknown spells */
2180 if (j >= 99) continue;
2182 /* Forget it (if learned) */
2184 (p_ptr->spell_learned1 & (1L << j)) :
2185 (p_ptr->spell_learned2 & (1L << (j - 32))))
2187 /* Mark as forgotten */
2190 p_ptr->spell_forgotten1 |= (1L << j);
2191 which = p_ptr->realm1;
2195 p_ptr->spell_forgotten2 |= (1L << (j - 32));
2196 which = p_ptr->realm2;
2199 /* No longer known */
2202 p_ptr->spell_learned1 &= ~(1L << j);
2203 which = p_ptr->realm1;
2207 p_ptr->spell_learned2 &= ~(1L << (j - 32));
2208 which = p_ptr->realm2;
2213 msg_format("%s¤Î%s¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡£",
2214 spell_names[technic2magic(which)-1][j%32], p );
2216 msg_format("You have forgotten the %s of %s.", p,
2217 spell_names[technic2magic(which)-1][j%32]);
2221 /* One more can be learned */
2222 p_ptr->new_spells++;
2227 /* Check for spells to remember */
2228 for (i = 0; i < 64; i++)
2230 /* None left to remember */
2231 if (p_ptr->new_spells <= 0) break;
2233 /* Efficiency -- all done */
2234 if (!p_ptr->spell_forgotten1 && !p_ptr->spell_forgotten2) break;
2236 /* Get the next spell we learned */
2237 j = p_ptr->spell_order[i];
2239 /* Skip unknown spells */
2242 /* Access the spell */
2243 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
2246 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
2248 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
2251 s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
2253 s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
2255 /* Skip spells we cannot remember */
2256 if (s_ptr->slevel > p_ptr->lev) continue;
2258 /* First set of spells */
2260 (p_ptr->spell_forgotten1 & (1L << j)) :
2261 (p_ptr->spell_forgotten2 & (1L << (j - 32))))
2263 /* No longer forgotten */
2266 p_ptr->spell_forgotten1 &= ~(1L << j);
2267 which = p_ptr->realm1;
2271 p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
2272 which = p_ptr->realm2;
2275 /* Known once more */
2278 p_ptr->spell_learned1 |= (1L << j);
2279 which = p_ptr->realm1;
2283 p_ptr->spell_learned2 |= (1L << (j - 32));
2284 which = p_ptr->realm2;
2289 msg_format("%s¤Î%s¤ò»×¤¤½Ð¤·¤¿¡£",
2290 spell_names[technic2magic(which)-1][j%32], p );
2292 msg_format("You have remembered the %s of %s.",
2293 p, spell_names[technic2magic(which)-1][j%32]);
2297 /* One less can be learned */
2298 p_ptr->new_spells--;
2304 if (p_ptr->realm2 == REALM_NONE)
2306 /* Count spells that can be learned */
2307 for (j = 0; j < 32; j++)
2309 if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1-MIN_TECHNIC][j];
2310 else s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
2312 /* Skip spells we cannot remember */
2313 if (s_ptr->slevel > p_ptr->lev) continue;
2315 /* Skip spells we already know */
2316 if (p_ptr->spell_learned1 & (1L << j))
2325 if ((p_ptr->new_spells > k) && ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK))) p_ptr->new_spells = k;
2328 if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
2330 /* Spell count changed */
2331 if (p_ptr->old_spells != p_ptr->new_spells)
2333 /* Message if needed */
2334 if (p_ptr->new_spells)
2338 if( p_ptr->new_spells < 10 ){
2339 msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
2341 msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
2344 msg_format("You can learn %d more %s%s.",
2345 p_ptr->new_spells, p,
2346 (p_ptr->new_spells != 1) ? "s" : "");
2351 /* Save the new_spells value */
2352 p_ptr->old_spells = p_ptr->new_spells;
2354 /* Redraw Study Status */
2355 p_ptr->redraw |= (PR_STUDY);
2357 /* Redraw object recall */
2358 p_ptr->window |= (PW_OBJECT);
2364 * Calculate maximum mana. You do not need to know any spells.
2365 * Note that mana is lowered by heavy (or inappropriate) armor.
2367 * This function induces status messages.
2369 static void calc_mana(void)
2371 int msp, levels, cur_wgt, max_wgt;
2376 /* Hack -- Must be literate */
2377 if (!mp_ptr->spell_book) return;
2379 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
2380 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
2381 (p_ptr->pclass == CLASS_BLUE_MAGE))
2383 levels = p_ptr->lev;
2387 if(mp_ptr->spell_first > p_ptr->lev)
2392 /* Display mana later */
2393 p_ptr->redraw |= (PR_MANA);
2397 /* Extract "effective" player level */
2398 levels = (p_ptr->lev - mp_ptr->spell_first) + 1;
2401 if (p_ptr->pclass == CLASS_SAMURAI)
2403 msp = (adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
2404 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
2408 /* Extract total mana */
2409 msp = adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] * (levels+3) / 4;
2411 /* Hack -- usually add one mana */
2414 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
2416 if (msp && (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp/2;
2418 /* Hack: High mages have a 25% mana bonus */
2419 if (msp && (p_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
2421 if (msp && (p_ptr->pclass == CLASS_SORCERER)) msp += msp*(25+p_ptr->lev)/100;
2424 /* Only mages are affected */
2425 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
2427 u32b flgs[TR_FLAG_SIZE];
2429 /* Assume player is not encumbered by gloves */
2430 p_ptr->cumber_glove = FALSE;
2432 /* Get the gloves */
2433 o_ptr = &inventory[INVEN_HANDS];
2435 /* Examine the gloves */
2436 object_flags(o_ptr, flgs);
2438 /* Normal gloves hurt mage-type spells */
2440 !(have_flag(flgs, TR_FREE_ACT)) &&
2441 !(have_flag(flgs, TR_MAGIC_MASTERY)) &&
2442 !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
2445 p_ptr->cumber_glove = TRUE;
2448 msp = (3 * msp) / 4;
2453 /* Assume player not encumbered by armor */
2454 p_ptr->cumber_armor = FALSE;
2456 /* Weigh the armor */
2458 if(inventory[INVEN_RARM].tval> TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
2459 if(inventory[INVEN_LARM].tval> TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
2460 cur_wgt += inventory[INVEN_BODY].weight;
2461 cur_wgt += inventory[INVEN_HEAD].weight;
2462 cur_wgt += inventory[INVEN_OUTER].weight;
2463 cur_wgt += inventory[INVEN_HANDS].weight;
2464 cur_wgt += inventory[INVEN_FEET].weight;
2466 /* Subtract a percentage of maximum mana. */
2467 switch (p_ptr->pclass)
2469 /* For these classes, mana is halved if armour
2470 * is 30 pounds over their weight limit. */
2472 case CLASS_HIGH_MAGE:
2473 case CLASS_BLUE_MAGE:
2475 case CLASS_FORCETRAINER:
2476 case CLASS_SORCERER:
2478 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
2479 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
2483 /* Mana halved if armour is 40 pounds over weight limit. */
2488 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight*2/3;
2489 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight*2/3;
2493 case CLASS_MINDCRAFTER:
2494 case CLASS_BEASTMASTER:
2495 case CLASS_MIRROR_MASTER:
2497 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/2;
2498 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/2;
2502 /* Mana halved if armour is 50 pounds over weight limit. */
2505 case CLASS_RED_MAGE:
2506 case CLASS_WARRIOR_MAGE:
2508 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/3;
2509 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/3;
2513 /* Mana halved if armour is 60 pounds over weight limit. */
2515 case CLASS_CHAOS_WARRIOR:
2517 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/5;
2518 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/5;
2522 /* For new classes created, but not yet added to this formula. */
2529 /* Determine the weight allowance */
2530 max_wgt = mp_ptr->spell_weight;
2532 /* Heavy armor penalizes mana by a percentage. -LM- */
2533 if ((cur_wgt - max_wgt) > 0)
2536 p_ptr->cumber_armor = TRUE;
2538 /* Subtract a percentage of maximum mana. */
2539 switch (p_ptr->pclass)
2541 /* For these classes, mana is halved if armour
2542 * is 30 pounds over their weight limit. */
2544 case CLASS_HIGH_MAGE:
2545 case CLASS_BLUE_MAGE:
2547 msp -= msp * (cur_wgt - max_wgt) / 600;
2551 /* Mana halved if armour is 40 pounds over weight limit. */
2553 case CLASS_MINDCRAFTER:
2554 case CLASS_BEASTMASTER:
2556 case CLASS_FORCETRAINER:
2558 case CLASS_MIRROR_MASTER:
2560 msp -= msp * (cur_wgt - max_wgt) / 800;
2564 case CLASS_SORCERER:
2566 msp -= msp * (cur_wgt - max_wgt) / 900;
2570 /* Mana halved if armour is 50 pounds over weight limit. */
2574 case CLASS_RED_MAGE:
2576 msp -= msp * (cur_wgt - max_wgt) / 1000;
2580 /* Mana halved if armour is 60 pounds over weight limit. */
2582 case CLASS_CHAOS_WARRIOR:
2583 case CLASS_WARRIOR_MAGE:
2585 msp -= msp * (cur_wgt - max_wgt) / 1200;
2591 p_ptr->cumber_armor = FALSE;
2595 /* For new classes created, but not yet added to this formula. */
2598 msp -= msp * (cur_wgt - max_wgt) / 800;
2604 /* Mana can never be negative */
2605 if (msp < 0) msp = 0;
2608 /* Maximum mana has changed */
2609 if (p_ptr->msp != msp)
2611 /* Enforce maximum */
2612 if ((p_ptr->csp >= msp) && (p_ptr->pclass != CLASS_SAMURAI))
2615 p_ptr->csp_frac = 0;
2619 /* ¥ì¥Ù¥ë¥¢¥Ã¥×¤Î»þ¤Ï¾å¾ºÎ̤òɽ¼¨¤¹¤ë */
2620 if ((level_up == 1) && (msp > p_ptr->msp))
2622 msg_format("ºÇÂç¥Þ¥¸¥Ã¥¯¡¦¥Ý¥¤¥ó¥È¤¬ %d Áý²Ã¤·¤¿¡ª",
2623 (msp - p_ptr->msp));
2629 /* Display mana later */
2630 p_ptr->redraw |= (PR_MANA);
2633 p_ptr->window |= (PW_PLAYER);
2634 p_ptr->window |= (PW_SPELL);
2638 /* Hack -- handle "xtra" mode */
2639 if (character_xtra) return;
2641 /* Take note when "glove state" changes */
2642 if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
2645 if (p_ptr->cumber_glove)
2648 msg_print("¼ê¤¬Ê¤¤ï¤ì¤Æ¼öʸ¤¬¾§¤¨¤Ë¤¯¤¤´¶¤¸¤¬¤¹¤ë¡£");
2650 msg_print("Your covered hands feel unsuitable for spellcasting.");
2657 msg_print("¤³¤Î¼ê¤Î¾õÂ֤ʤ顢¤°¤Ã¤È¼öʸ¤¬¾§¤¨¤ä¤¹¤¤´¶¤¸¤À¡£");
2659 msg_print("Your hands feel more suitable for spellcasting.");
2665 p_ptr->old_cumber_glove = p_ptr->cumber_glove;
2669 /* Take note when "armor state" changes */
2670 if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
2673 if (p_ptr->cumber_armor)
2676 msg_print("ÁõÈ÷¤Î½Å¤µ¤ÇÆ°¤¤¬Æߤ¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤Æ¤¤¤ë¡£");
2678 msg_print("The weight of your equipment encumbers your movement.");
2685 msg_print("¤°¤Ã¤È³Ú¤ËÂΤòÆ°¤«¤»¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
2687 msg_print("You feel able to move more freely.");
2693 p_ptr->old_cumber_armor = p_ptr->cumber_armor;
2700 * Calculate the players (maximal) hit points
2701 * Adjust current hitpoints if necessary
2703 static void calc_hitpoints(void)
2708 /* Un-inflate "half-hitpoint bonus per level" value */
2709 bonus = ((int)(adj_con_mhp[p_ptr->stat_ind[A_CON]]) - 128) * p_ptr->lev / 4;
2711 /* Calculate hitpoints */
2712 mhp = p_ptr->player_hp[p_ptr->lev - 1];
2714 if (p_ptr->mimic_form)
2716 if (p_ptr->pclass == CLASS_SORCERER)
2717 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
2719 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
2720 mhp = mhp * tmp_hitdie / p_ptr->hitdie;
2723 if (p_ptr->pclass == CLASS_SORCERER)
2725 if (p_ptr->lev < 30)
2726 mhp = (mhp * (45+p_ptr->lev) / 100);
2728 mhp = (mhp * 75 / 100);
2729 bonus = (bonus * 65 / 100);
2734 if (p_ptr->pclass == CLASS_BERSERKER)
2736 mhp = mhp*(110+(((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 110))/100;
2739 /* Always have at least one hitpoint per level */
2740 if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1;
2742 /* Factor in the hero / superhero settings */
2743 if (IS_HERO()) mhp += 10;
2744 if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
2745 if (p_ptr->tsuyoshi) mhp += 50;
2747 /* New maximum hitpoints */
2748 if (p_ptr->mhp != mhp)
2750 /* Enforce maximum */
2751 if (p_ptr->chp >= mhp)
2754 p_ptr->chp_frac = 0;
2758 /* ¥ì¥Ù¥ë¥¢¥Ã¥×¤Î»þ¤Ï¾å¾ºÎ̤òɽ¼¨¤¹¤ë */
2759 if ((level_up == 1) && (mhp > p_ptr->mhp))
2761 msg_format("ºÇÂç¥Ò¥Ã¥È¡¦¥Ý¥¤¥ó¥È¤¬ %d Áý²Ã¤·¤¿¡ª",
2762 (mhp - p_ptr->mhp) );
2765 /* Save the new max-hitpoints */
2768 /* Display hitpoints (later) */
2769 p_ptr->redraw |= (PR_HP);
2772 p_ptr->window |= (PW_PLAYER);
2779 * Extract and set the current "lite radius"
2781 * SWD: Experimental modification: multiple light sources have additive effect.
2784 static void calc_torch(void)
2788 u32b flgs[TR_FLAG_SIZE];
2790 /* Assume no light */
2791 p_ptr->cur_lite = 0;
2793 /* Loop through all wielded items */
2794 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2796 o_ptr = &inventory[i];
2798 /* Examine actual lites */
2799 if ((i == INVEN_LITE) && (o_ptr->k_idx) && (o_ptr->tval == TV_LITE))
2801 if (o_ptr->name2 == EGO_LITE_DARKNESS)
2803 if (o_ptr->sval == SV_LITE_TORCH)
2805 p_ptr->cur_lite -= 1;
2808 /* Lanterns (with fuel) provide more lite */
2809 else if (o_ptr->sval == SV_LITE_LANTERN)
2811 p_ptr->cur_lite -= 2;
2814 else if (o_ptr->sval == SV_LITE_FEANOR)
2816 p_ptr->cur_lite -= 3;
2819 /* Torches (with fuel) provide some lite */
2820 else if ((o_ptr->sval == SV_LITE_TORCH) && (o_ptr->xtra4 > 0))
2822 p_ptr->cur_lite += 1;
2825 /* Lanterns (with fuel) provide more lite */
2826 else if ((o_ptr->sval == SV_LITE_LANTERN) && (o_ptr->xtra4 > 0))
2828 p_ptr->cur_lite += 2;
2831 else if (o_ptr->sval == SV_LITE_FEANOR)
2833 p_ptr->cur_lite += 2;
2836 /* Artifact Lites provide permanent, bright, lite */
2837 else if (artifact_p(o_ptr))
2839 p_ptr->cur_lite += 3;
2842 if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
2846 /* Skip empty slots */
2847 if (!o_ptr->k_idx) continue;
2849 /* Extract the flags */
2850 object_flags(o_ptr, flgs);
2852 /* does this item glow? */
2853 if (have_flag(flgs, TR_LITE))
2855 if ((o_ptr->name2 == EGO_DARK) || (o_ptr->name1 == ART_NIGHT)) p_ptr->cur_lite--;
2856 else p_ptr->cur_lite++;
2862 /* max radius is 14 (was 5) without rewriting other code -- */
2863 /* see cave.c:update_lite() and defines.h:LITE_MAX */
2864 if (d_info[dungeon_type].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
2865 p_ptr->cur_lite = 1;
2868 * check if the player doesn't have light radius,
2869 * but does weakly glow as an intrinsic.
2871 if (p_ptr->cur_lite <= 0 && p_ptr->lite) p_ptr->cur_lite++;
2873 if (p_ptr->cur_lite > 14) p_ptr->cur_lite = 14;
2874 if (p_ptr->cur_lite < 0) p_ptr->cur_lite = 0;
2876 /* end experimental mods */
2878 /* Notice changes in the "lite radius" */
2879 if (p_ptr->old_lite != p_ptr->cur_lite)
2881 /* Update the lite */
2882 /* Hack -- PU_MON_LITE for monsters' darkness */
2883 p_ptr->update |= (PU_LITE | PU_MON_LITE);
2885 /* Update the monsters */
2886 p_ptr->update |= (PU_MONSTERS);
2888 /* Remember the old lite */
2889 p_ptr->old_lite = p_ptr->cur_lite;
2891 if ((p_ptr->cur_lite > 0) && (p_ptr->special_defense & NINJA_S_STEALTH))
2892 set_superstealth(FALSE);
2899 * Computes current weight limit.
2901 static int weight_limit(void)
2905 /* Weight limit based only on strength */
2906 i = adj_str_wgt[p_ptr->stat_ind[A_STR]] * 100;
2907 if (p_ptr->pclass == CLASS_BERSERKER) i = i*3/2;
2909 /* Return the result */
2914 bool buki_motteruka(int i)
2916 return ((inventory[i].k_idx && inventory[i].tval >= TV_DIGGING && inventory[i].tval <= TV_SWORD) ? TRUE : FALSE);
2921 * Calculate the players current "state", taking into account
2922 * not only race/class intrinsics, but also objects being worn
2923 * and temporary spell effects.
2925 * See also calc_mana() and calc_hitpoints().
2927 * Take note of the new "speed code", in particular, a very strong
2928 * player will start slowing down as soon as he reaches 150 pounds,
2929 * but not until he reaches 450 pounds will he be half as fast as
2930 * a normal kobold. This both hurts and helps the player, hurts
2931 * because in the old days a player could just avoid 300 pounds,
2932 * and helps because now carrying 300 pounds is not very painful.
2934 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
2935 * damage, since that would affect non-combat things. These values
2936 * are actually added in later, at the appropriate place.
2938 * This function induces various "status" messages.
2940 void calc_bonuses(void)
2942 int i, j, hold, neutral[2];
2947 u32b flgs[TR_FLAG_SIZE];
2949 bool yoiyami = FALSE;
2950 bool down_saving = FALSE;
2952 bool have_dd_s = FALSE, have_dd_t = FALSE;
2954 bool have_sw = FALSE, have_kabe = FALSE;
2955 bool easy_2weapon = FALSE;
2956 s16b this_o_idx, next_o_idx = 0;
2957 player_race *tmp_rp_ptr;
2959 /* Save the old vision stuff */
2960 bool old_telepathy = p_ptr->telepathy;
2961 bool old_esp_animal = p_ptr->esp_animal;
2962 bool old_esp_undead = p_ptr->esp_undead;
2963 bool old_esp_demon = p_ptr->esp_demon;
2964 bool old_esp_orc = p_ptr->esp_orc;
2965 bool old_esp_troll = p_ptr->esp_troll;
2966 bool old_esp_giant = p_ptr->esp_giant;
2967 bool old_esp_dragon = p_ptr->esp_dragon;
2968 bool old_esp_human = p_ptr->esp_human;
2969 bool old_esp_evil = p_ptr->esp_evil;
2970 bool old_esp_good = p_ptr->esp_good;
2971 bool old_esp_nonliving = p_ptr->esp_nonliving;
2972 bool old_esp_unique = p_ptr->esp_unique;
2973 bool old_see_inv = p_ptr->see_inv;
2974 bool old_mighty_throw = p_ptr->mighty_throw;
2976 /* Save the old armor class */
2977 bool old_dis_ac = p_ptr->dis_ac;
2978 bool old_dis_to_a = p_ptr->dis_to_a;
2981 /* Clear extra blows/shots */
2982 extra_blows[0] = extra_blows[1] = extra_shots = 0;
2984 /* Clear the stat modifiers */
2985 for (i = 0; i < 6; i++) p_ptr->stat_add[i] = 0;
2988 /* Clear the Displayed/Real armor class */
2989 p_ptr->dis_ac = p_ptr->ac = 0;
2991 /* Clear the Displayed/Real Bonuses */
2992 p_ptr->dis_to_h[0] = p_ptr->to_h[0] = 0;
2993 p_ptr->dis_to_h[1] = p_ptr->to_h[1] = 0;
2994 p_ptr->dis_to_d[0] = p_ptr->to_d[0] = 0;
2995 p_ptr->dis_to_d[1] = p_ptr->to_d[1] = 0;
2996 p_ptr->dis_to_h_b = p_ptr->to_h_b = 0;
2997 p_ptr->dis_to_a = p_ptr->to_a = 0;
3001 p_ptr->to_m_chance = 0;
3003 /* Clear the Extra Dice Bonuses */
3004 p_ptr->to_dd[0] = p_ptr->to_ds[0] = 0;
3005 p_ptr->to_dd[1] = p_ptr->to_ds[1] = 0;
3007 /* Start with "normal" speed */
3010 /* Start with a single blow per turn */
3011 p_ptr->num_blow[0] = 1;
3012 p_ptr->num_blow[1] = 1;
3014 /* Start with a single shot per turn */
3015 p_ptr->num_fire = 100;
3017 /* Reset the "xtra" tval */
3018 p_ptr->tval_xtra = 0;
3020 /* Reset the "ammo" tval */
3021 p_ptr->tval_ammo = 0;
3023 /* Clear all the flags */
3025 p_ptr->bless_blade = FALSE;
3026 p_ptr->xtra_might = FALSE;
3027 p_ptr->impact[0] = FALSE;
3028 p_ptr->impact[1] = FALSE;
3029 p_ptr->pass_wall = FALSE;
3030 p_ptr->kill_wall = FALSE;
3031 p_ptr->dec_mana = FALSE;
3032 p_ptr->easy_spell = FALSE;
3033 p_ptr->heavy_spell = FALSE;
3034 p_ptr->see_inv = FALSE;
3035 p_ptr->free_act = FALSE;
3036 p_ptr->slow_digest = FALSE;
3037 p_ptr->regenerate = FALSE;
3038 p_ptr->can_swim = FALSE;
3039 p_ptr->ffall = FALSE;
3040 p_ptr->hold_life = FALSE;
3041 p_ptr->telepathy = FALSE;
3042 p_ptr->esp_animal = FALSE;
3043 p_ptr->esp_undead = FALSE;
3044 p_ptr->esp_demon = FALSE;
3045 p_ptr->esp_orc = FALSE;
3046 p_ptr->esp_troll = FALSE;
3047 p_ptr->esp_giant = FALSE;
3048 p_ptr->esp_dragon = FALSE;
3049 p_ptr->esp_human = FALSE;
3050 p_ptr->esp_evil = FALSE;
3051 p_ptr->esp_good = FALSE;
3052 p_ptr->esp_nonliving = FALSE;
3053 p_ptr->esp_unique = FALSE;
3054 p_ptr->lite = FALSE;
3055 p_ptr->sustain_str = FALSE;
3056 p_ptr->sustain_int = FALSE;
3057 p_ptr->sustain_wis = FALSE;
3058 p_ptr->sustain_con = FALSE;
3059 p_ptr->sustain_dex = FALSE;
3060 p_ptr->sustain_chr = FALSE;
3061 p_ptr->resist_acid = FALSE;
3062 p_ptr->resist_elec = FALSE;
3063 p_ptr->resist_fire = FALSE;
3064 p_ptr->resist_cold = FALSE;
3065 p_ptr->resist_pois = FALSE;
3066 p_ptr->resist_conf = FALSE;
3067 p_ptr->resist_sound = FALSE;
3068 p_ptr->resist_lite = FALSE;
3069 p_ptr->resist_dark = FALSE;
3070 p_ptr->resist_chaos = FALSE;
3071 p_ptr->resist_disen = FALSE;
3072 p_ptr->resist_shard = FALSE;
3073 p_ptr->resist_nexus = FALSE;
3074 p_ptr->resist_blind = FALSE;
3075 p_ptr->resist_neth = FALSE;
3076 p_ptr->resist_time = FALSE;
3077 p_ptr->resist_fear = FALSE;
3078 p_ptr->reflect = FALSE;
3079 p_ptr->sh_fire = FALSE;
3080 p_ptr->sh_elec = FALSE;
3081 p_ptr->sh_cold = FALSE;
3082 p_ptr->anti_magic = FALSE;
3083 p_ptr->anti_tele = FALSE;
3084 p_ptr->warning = FALSE;
3085 p_ptr->mighty_throw = FALSE;
3086 p_ptr->see_nocto = FALSE;
3088 p_ptr->immune_acid = FALSE;
3089 p_ptr->immune_elec = FALSE;
3090 p_ptr->immune_fire = FALSE;
3091 p_ptr->immune_cold = FALSE;
3093 p_ptr->ryoute = FALSE;
3094 p_ptr->migite = FALSE;
3095 p_ptr->hidarite = FALSE;
3096 p_ptr->no_flowed = FALSE;
3100 if (p_ptr->mimic_form) tmp_rp_ptr = &mimic_info[p_ptr->mimic_form];
3101 else tmp_rp_ptr = &race_info[p_ptr->prace];
3103 /* Base infravision (purely racial) */
3104 p_ptr->see_infra = tmp_rp_ptr->infra;
3106 /* Base skill -- disarming */
3107 p_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
3109 /* Base skill -- magic devices */
3110 p_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
3112 /* Base skill -- saving throw */
3113 p_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
3115 /* Base skill -- stealth */
3116 p_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
3118 /* Base skill -- searching ability */
3119 p_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
3121 /* Base skill -- searching frequency */
3122 p_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
3124 /* Base skill -- combat (normal) */
3125 p_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
3127 /* Base skill -- combat (shooting) */
3128 p_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
3130 /* Base skill -- combat (throwing) */
3131 p_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
3133 /* Base skill -- digging */
3134 p_ptr->skill_dig = 0;
3136 if (buki_motteruka(INVEN_RARM) && (empty_hands(FALSE) & EMPTY_HAND_LARM) && ((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;
3137 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE))) p_ptr->ryoute = TRUE;
3138 if (buki_motteruka(INVEN_RARM) || !buki_motteruka(INVEN_LARM)) p_ptr->migite = TRUE;
3139 if (buki_motteruka(INVEN_LARM)) p_ptr->hidarite = TRUE;
3141 if (p_ptr->special_defense & KAMAE_MASK)
3143 if (!(empty_hands(TRUE) & EMPTY_HAND_RARM))
3145 set_action(ACTION_NONE);
3149 switch (p_ptr->pclass)
3152 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
3153 if (p_ptr->lev > 44) p_ptr->regenerate = TRUE;
3156 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
3158 case CLASS_CHAOS_WARRIOR:
3159 if (p_ptr->lev > 29) p_ptr->resist_chaos = TRUE;
3160 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
3162 case CLASS_MINDCRAFTER:
3163 if (p_ptr->lev > 9) p_ptr->resist_fear = TRUE;
3164 if (p_ptr->lev > 19) p_ptr->sustain_wis = TRUE;
3165 if (p_ptr->lev > 29) p_ptr->resist_conf = TRUE;
3166 if (p_ptr->lev > 39) p_ptr->telepathy = TRUE;
3169 case CLASS_FORCETRAINER:
3170 /* Unencumbered Monks become faster every 10 levels */
3171 if (!(heavy_armor()))
3173 if (!(prace_is_(RACE_KLACKON) ||
3174 prace_is_(RACE_SPRITE) ||
3175 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
3176 new_speed += (p_ptr->lev) / 10;
3178 /* Free action if unencumbered at level 25 */
3179 if (p_ptr->lev > 24)
3180 p_ptr->free_act = TRUE;
3183 case CLASS_SORCERER:
3185 p_ptr->dis_to_a -= 50;
3188 p_ptr->resist_sound = TRUE;
3191 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
3193 case CLASS_BERSERKER:
3195 p_ptr->sustain_str = TRUE;
3196 p_ptr->sustain_dex = TRUE;
3197 p_ptr->sustain_con = TRUE;
3198 p_ptr->regenerate = TRUE;
3199 p_ptr->free_act = TRUE;
3201 if (p_ptr->lev > 29) new_speed++;
3202 if (p_ptr->lev > 39) new_speed++;
3203 if (p_ptr->lev > 44) new_speed++;
3204 if (p_ptr->lev > 49) new_speed++;
3205 p_ptr->to_a += 10+p_ptr->lev/2;
3206 p_ptr->dis_to_a += 10+p_ptr->lev/2;
3207 p_ptr->skill_dig += (100+p_ptr->lev*8);
3208 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
3209 p_ptr->redraw |= PR_STATUS;
3211 case CLASS_MIRROR_MASTER:
3212 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
3215 /* Unencumbered Ninjas become faster every 10 levels */
3218 new_speed -= (p_ptr->lev) / 10;
3219 p_ptr->skill_stl -= (p_ptr->lev)/10;
3221 else if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
3224 if (!(prace_is_(RACE_KLACKON) ||
3225 prace_is_(RACE_SPRITE) ||
3226 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
3227 new_speed += (p_ptr->lev) / 10;
3228 p_ptr->skill_stl += (p_ptr->lev)/10;
3230 /* Free action if unencumbered at level 25 */
3231 if (p_ptr->lev > 24)
3232 p_ptr->free_act = TRUE;
3234 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
3236 p_ptr->to_a += p_ptr->lev/2+5;
3237 p_ptr->dis_to_a += p_ptr->lev/2+5;
3239 p_ptr->slow_digest = TRUE;
3240 p_ptr->resist_fear = TRUE;
3241 if (p_ptr->lev > 19) p_ptr->resist_pois = TRUE;
3242 if (p_ptr->lev > 24) p_ptr->sustain_dex = TRUE;
3243 if (p_ptr->lev > 29) p_ptr->see_inv = TRUE;
3244 if (p_ptr->lev > 44)
3246 p_ptr->oppose_pois = 1;
3247 p_ptr->redraw |= PR_STATUS;
3249 p_ptr->see_nocto = TRUE;
3254 if (p_ptr->mimic_form)
3256 switch(p_ptr->mimic_form)
3259 p_ptr->hold_life=TRUE;
3260 p_ptr->resist_chaos=TRUE;
3261 p_ptr->resist_neth=TRUE;
3262 p_ptr->resist_fire=TRUE;
3263 p_ptr->oppose_fire = 1;
3264 p_ptr->see_inv=TRUE;
3266 p_ptr->redraw |= PR_STATUS;
3268 p_ptr->dis_to_a += 10;
3270 case MIMIC_DEMON_LORD:
3271 p_ptr->hold_life=TRUE;
3272 p_ptr->resist_chaos=TRUE;
3273 p_ptr->resist_neth=TRUE;
3274 p_ptr->immune_fire=TRUE;
3275 p_ptr->resist_acid = TRUE;
3276 p_ptr->resist_fire=TRUE;
3277 p_ptr->resist_cold = TRUE;
3278 p_ptr->resist_elec = TRUE;
3279 p_ptr->resist_pois = TRUE;
3280 p_ptr->resist_conf = TRUE;
3281 p_ptr->resist_disen = TRUE;
3282 p_ptr->resist_nexus = TRUE;
3283 p_ptr->resist_fear = TRUE;
3284 p_ptr->sh_fire = TRUE;
3285 p_ptr->see_inv = TRUE;
3286 p_ptr->telepathy = TRUE;
3287 p_ptr->ffall = TRUE;
3288 p_ptr->kill_wall = TRUE;
3291 p_ptr->dis_to_a += 20;
3294 p_ptr->resist_dark = TRUE;
3295 p_ptr->hold_life = TRUE;
3296 p_ptr->resist_neth = TRUE;
3297 p_ptr->resist_cold = TRUE;
3298 p_ptr->resist_pois = TRUE;
3299 p_ptr->see_inv = TRUE;
3302 p_ptr->dis_to_a += 10;
3303 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3309 switch (p_ptr->prace)
3312 p_ptr->resist_lite = TRUE;
3315 p_ptr->sustain_dex = TRUE;
3318 p_ptr->free_act = TRUE;
3321 p_ptr->resist_blind = TRUE;
3324 p_ptr->resist_dark = TRUE;
3326 case RACE_HALF_TROLL:
3327 p_ptr->sustain_str = TRUE;
3329 if (p_ptr->lev > 14)
3331 /* High level trolls heal fast... */
3332 p_ptr->regenerate = TRUE;
3334 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_BERSERKER)
3336 p_ptr->slow_digest = TRUE;
3337 /* Let's not make Regeneration
3338 * a disadvantage for the poor warriors who can
3339 * never learn a spell that satisfies hunger (actually
3340 * neither can rogues, but half-trolls are not
3341 * supposed to play rogues) */
3346 p_ptr->sustain_con = TRUE;
3347 p_ptr->regenerate = TRUE; /* Amberites heal fast... */
3350 p_ptr->resist_lite = TRUE;
3351 p_ptr->see_inv = TRUE;
3353 case RACE_BARBARIAN:
3354 p_ptr->resist_fear = TRUE;
3356 case RACE_HALF_OGRE:
3357 p_ptr->resist_dark = TRUE;
3358 p_ptr->sustain_str = TRUE;
3360 case RACE_HALF_GIANT:
3361 p_ptr->sustain_str = TRUE;
3362 p_ptr->resist_shard = TRUE;
3364 case RACE_HALF_TITAN:
3365 p_ptr->resist_chaos = TRUE;
3368 p_ptr->resist_sound = TRUE;
3371 p_ptr->resist_acid = TRUE;
3372 if (p_ptr->lev > 19) p_ptr->immune_acid = TRUE;
3375 p_ptr->resist_conf = TRUE;
3376 p_ptr->resist_acid = TRUE;
3378 /* Klackons become faster */
3379 new_speed += (p_ptr->lev) / 10;
3382 p_ptr->resist_pois = TRUE;
3385 p_ptr->resist_disen = TRUE;
3386 p_ptr->resist_dark = TRUE;
3389 p_ptr->resist_dark = TRUE;
3390 if (p_ptr->lev > 19) p_ptr->see_inv = TRUE;
3392 case RACE_DRACONIAN:
3393 p_ptr->ffall = TRUE;
3394 if (p_ptr->lev > 4) p_ptr->resist_fire = TRUE;
3395 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
3396 if (p_ptr->lev > 14) p_ptr->resist_acid = TRUE;
3397 if (p_ptr->lev > 19) p_ptr->resist_elec = TRUE;
3398 if (p_ptr->lev > 34) p_ptr->resist_pois = TRUE;
3400 case RACE_MIND_FLAYER:
3401 p_ptr->sustain_int = TRUE;
3402 p_ptr->sustain_wis = TRUE;
3403 if (p_ptr->lev > 14) p_ptr->see_inv = TRUE;
3404 if (p_ptr->lev > 29) p_ptr->telepathy = TRUE;
3407 p_ptr->resist_fire = TRUE;
3408 if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
3411 p_ptr->slow_digest = TRUE;
3412 p_ptr->free_act = TRUE;
3413 p_ptr->see_inv = TRUE;
3414 p_ptr->resist_pois = TRUE;
3415 if (p_ptr->lev > 34) p_ptr->hold_life = TRUE;
3418 p_ptr->resist_shard = TRUE;
3419 p_ptr->hold_life = TRUE;
3420 p_ptr->see_inv = TRUE;
3421 p_ptr->resist_pois = TRUE;
3422 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
3425 p_ptr->resist_neth = TRUE;
3426 p_ptr->hold_life = TRUE;
3427 p_ptr->see_inv = TRUE;
3428 p_ptr->resist_pois = TRUE;
3429 p_ptr->slow_digest = TRUE;
3430 if (p_ptr->lev > 4) p_ptr->resist_cold = TRUE;
3433 p_ptr->resist_dark = TRUE;
3434 p_ptr->hold_life = TRUE;
3435 p_ptr->resist_neth = TRUE;
3436 p_ptr->resist_cold = TRUE;
3437 p_ptr->resist_pois = TRUE;
3438 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3441 p_ptr->ffall = TRUE;
3442 p_ptr->free_act = TRUE;
3443 p_ptr->resist_neth = TRUE;
3444 p_ptr->hold_life = TRUE;
3445 p_ptr->see_inv = TRUE;
3446 p_ptr->resist_pois = TRUE;
3447 p_ptr->slow_digest = TRUE;
3448 p_ptr->resist_cold = TRUE;
3449 p_ptr->pass_wall = TRUE;
3450 if (p_ptr->lev > 34) p_ptr->telepathy = TRUE;
3453 p_ptr->ffall = TRUE;
3454 p_ptr->resist_lite = TRUE;
3456 /* Sprites become faster */
3457 new_speed += (p_ptr->lev) / 10;
3460 p_ptr->resist_conf = TRUE;
3461 p_ptr->resist_sound = TRUE;
3464 /* Ents dig like maniacs, but only with their hands. */
3465 if (!inventory[INVEN_RARM].k_idx)
3466 p_ptr->skill_dig += p_ptr->lev * 10;
3467 /* Ents get tougher and stronger as they age, but lose dexterity. */
3468 if (p_ptr->lev > 25) p_ptr->stat_add[A_STR]++;
3469 if (p_ptr->lev > 40) p_ptr->stat_add[A_STR]++;
3470 if (p_ptr->lev > 45) p_ptr->stat_add[A_STR]++;
3472 if (p_ptr->lev > 25) p_ptr->stat_add[A_DEX]--;
3473 if (p_ptr->lev > 40) p_ptr->stat_add[A_DEX]--;
3474 if (p_ptr->lev > 45) p_ptr->stat_add[A_DEX]--;
3476 if (p_ptr->lev > 25) p_ptr->stat_add[A_CON]++;
3477 if (p_ptr->lev > 40) p_ptr->stat_add[A_CON]++;
3478 if (p_ptr->lev > 45) p_ptr->stat_add[A_CON]++;
3481 p_ptr->ffall = TRUE;
3482 p_ptr->see_inv = TRUE;
3485 p_ptr->resist_fire = TRUE;
3486 p_ptr->resist_neth = TRUE;
3487 p_ptr->hold_life = TRUE;
3489 p_ptr->see_inv = TRUE;
3490 if (p_ptr->lev > 44)
3492 p_ptr->oppose_fire = 1;
3493 p_ptr->redraw |= PR_STATUS;
3497 p_ptr->sustain_con = TRUE;
3500 p_ptr->ffall = TRUE;
3503 p_ptr->resist_conf = TRUE;
3506 p_ptr->slow_digest = TRUE;
3507 p_ptr->free_act = TRUE;
3508 p_ptr->resist_pois = TRUE;
3509 p_ptr->hold_life = TRUE;
3517 if (p_ptr->ult_res || (p_ptr->special_defense & KATA_MUSOU))
3519 p_ptr->see_inv = TRUE;
3520 p_ptr->free_act = TRUE;
3521 p_ptr->slow_digest = TRUE;
3522 p_ptr->regenerate = TRUE;
3523 p_ptr->ffall = TRUE;
3524 p_ptr->hold_life = TRUE;
3525 p_ptr->telepathy = TRUE;
3527 p_ptr->sustain_str = TRUE;
3528 p_ptr->sustain_int = TRUE;
3529 p_ptr->sustain_wis = TRUE;
3530 p_ptr->sustain_con = TRUE;
3531 p_ptr->sustain_dex = TRUE;
3532 p_ptr->sustain_chr = TRUE;
3533 p_ptr->resist_acid = TRUE;
3534 p_ptr->resist_elec = TRUE;
3535 p_ptr->resist_fire = TRUE;
3536 p_ptr->resist_cold = TRUE;
3537 p_ptr->resist_pois = TRUE;
3538 p_ptr->resist_conf = TRUE;
3539 p_ptr->resist_sound = TRUE;
3540 p_ptr->resist_lite = TRUE;
3541 p_ptr->resist_dark = TRUE;
3542 p_ptr->resist_chaos = TRUE;
3543 p_ptr->resist_disen = TRUE;
3544 p_ptr->resist_shard = TRUE;
3545 p_ptr->resist_nexus = TRUE;
3546 p_ptr->resist_blind = TRUE;
3547 p_ptr->resist_neth = TRUE;
3548 p_ptr->resist_fear = TRUE;
3549 p_ptr->reflect = TRUE;
3550 p_ptr->sh_fire = TRUE;
3551 p_ptr->sh_elec = TRUE;
3552 p_ptr->sh_cold = TRUE;
3554 p_ptr->dis_to_a += 100;
3556 /* Temporary shield */
3557 else if (p_ptr->tsubureru || p_ptr->shield || p_ptr->magicdef)
3560 p_ptr->dis_to_a += 50;
3563 if (p_ptr->tim_res_nether)
3565 p_ptr->resist_neth = TRUE;
3567 if (p_ptr->tim_sh_fire)
3569 p_ptr->sh_fire = TRUE;
3571 if (p_ptr->tim_res_time)
3573 p_ptr->resist_time = TRUE;
3577 if (p_ptr->pseikaku == SEIKAKU_SEXY) p_ptr->cursed |= (TRC_AGGRAVATE);
3578 if (p_ptr->pseikaku == SEIKAKU_NAMAKE) p_ptr->to_m_chance += 10;
3579 if (p_ptr->pseikaku == SEIKAKU_KIREMONO) p_ptr->to_m_chance -= 3;
3580 if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) p_ptr->to_m_chance++;
3583 if (p_ptr->pseikaku == SEIKAKU_LUCKY) p_ptr->muta3 |= MUT3_GOOD_LUCK;
3585 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
3587 p_ptr->resist_blind = TRUE;
3588 p_ptr->resist_conf = TRUE;
3589 p_ptr->hold_life = TRUE;
3590 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
3592 if ((p_ptr->prace != RACE_KLACKON) && (p_ptr->prace != RACE_SPRITE))
3593 /* Munchkin become faster */
3594 new_speed += (p_ptr->lev) / 10 + 5;
3599 if (!(r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_PASS_WALL))
3600 p_ptr->pass_wall = FALSE;
3601 if (r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_KILL_WALL)
3602 p_ptr->pass_wall = TRUE;
3604 if (music_singing(MUSIC_WALL)) p_ptr->kill_wall = TRUE;
3606 if (p_ptr->kill_wall) p_ptr->pass_wall = TRUE;
3608 /* Hack -- apply racial/class stat maxes */
3609 /* Apply the racial modifiers */
3610 for (i = 0; i < 6; i++)
3612 /* Modify the stats for "race" */
3613 p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
3617 /* I'm adding the mutations here for the lack of a better place... */
3620 /* Hyper Strength */
3621 if (p_ptr->muta3 & MUT3_HYPER_STR)
3623 p_ptr->stat_add[A_STR] += 4;
3627 if (p_ptr->muta3 & MUT3_PUNY)
3629 p_ptr->stat_add[A_STR] -= 4;
3632 /* Living computer */
3633 if (p_ptr->muta3 & MUT3_HYPER_INT)
3635 p_ptr->stat_add[A_INT] += 4;
3636 p_ptr->stat_add[A_WIS] += 4;
3640 if (p_ptr->muta3 & MUT3_MORONIC)
3642 p_ptr->stat_add[A_INT] -= 4;
3643 p_ptr->stat_add[A_WIS] -= 4;
3646 if (p_ptr->muta3 & MUT3_RESILIENT)
3648 p_ptr->stat_add[A_CON] += 4;
3651 if (p_ptr->muta3 & MUT3_XTRA_FAT)
3653 p_ptr->stat_add[A_CON] += 2;
3657 if (p_ptr->muta3 & MUT3_ALBINO)
3659 p_ptr->stat_add[A_CON] -= 4;
3662 if (p_ptr->muta3 & MUT3_FLESH_ROT)
3664 p_ptr->stat_add[A_CON] -= 2;
3665 p_ptr->stat_add[A_CHR] -= 1;
3666 p_ptr->regenerate = FALSE;
3667 /* Cancel innate regeneration */
3670 if (p_ptr->muta3 & MUT3_SILLY_VOI)
3672 p_ptr->stat_add[A_CHR] -= 4;
3675 if (p_ptr->muta3 & MUT3_BLANK_FAC)
3677 p_ptr->stat_add[A_CHR] -= 1;
3680 if (p_ptr->muta3 & MUT3_XTRA_EYES)
3682 p_ptr->skill_fos += 15;
3683 p_ptr->skill_srh += 15;
3686 if (p_ptr->muta3 & MUT3_MAGIC_RES)
3688 p_ptr->skill_sav += (15 + (p_ptr->lev / 5));
3691 if (p_ptr->muta3 & MUT3_XTRA_NOIS)
3693 p_ptr->skill_stl -= 3;
3696 if (p_ptr->muta3 & MUT3_INFRAVIS)
3698 p_ptr->see_infra += 3;
3701 if (p_ptr->muta3 & MUT3_XTRA_LEGS)
3706 if (p_ptr->muta3 & MUT3_SHORT_LEG)
3711 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
3713 p_ptr->sh_elec = TRUE;
3716 if (p_ptr->muta3 & MUT3_FIRE_BODY)
3718 p_ptr->sh_fire = TRUE;
3722 if (p_ptr->muta3 & MUT3_WART_SKIN)
3724 p_ptr->stat_add[A_CHR] -= 2;
3726 p_ptr->dis_to_a += 5;
3729 if (p_ptr->muta3 & MUT3_SCALES)
3731 p_ptr->stat_add[A_CHR] -= 1;
3733 p_ptr->dis_to_a += 10;
3736 if (p_ptr->muta3 & MUT3_IRON_SKIN)
3738 p_ptr->stat_add[A_DEX] -= 1;
3740 p_ptr->dis_to_a += 25;
3743 if (p_ptr->muta3 & MUT3_WINGS)
3745 p_ptr->ffall = TRUE;
3748 if (p_ptr->muta3 & MUT3_FEARLESS)
3750 p_ptr->resist_fear = TRUE;
3753 if (p_ptr->muta3 & MUT3_REGEN)
3755 p_ptr->regenerate = TRUE;
3758 if (p_ptr->muta3 & MUT3_ESP)
3760 p_ptr->telepathy = TRUE;
3763 if (p_ptr->muta3 & MUT3_LIMBER)
3765 p_ptr->stat_add[A_DEX] += 3;
3768 if (p_ptr->muta3 & MUT3_ARTHRITIS)
3770 p_ptr->stat_add[A_DEX] -= 3;
3773 if (p_ptr->muta3 & MUT3_MOTION)
3775 p_ptr->free_act = TRUE;
3776 p_ptr->skill_stl += 1;
3779 if (p_ptr->muta3 & MUT3_ILL_NORM)
3781 p_ptr->stat_add[A_CHR] = 0;
3785 if (p_ptr->tsuyoshi)
3787 p_ptr->stat_add[A_STR] += 4;
3788 p_ptr->stat_add[A_CON] += 4;
3791 /* Scan the usable inventory */
3792 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3794 int bonus_to_h, bonus_to_d;
3795 o_ptr = &inventory[i];
3797 /* Skip non-objects */
3798 if (!o_ptr->k_idx) continue;
3800 /* Extract the item flags */
3801 object_flags(o_ptr, flgs);
3803 p_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
3804 if (o_ptr->name1 == ART_CHAINSWORD) p_ptr->cursed |= TRC_CHAINSWORD;
3807 if (have_flag(flgs, TR_STR)) p_ptr->stat_add[A_STR] += o_ptr->pval;
3808 if (have_flag(flgs, TR_INT)) p_ptr->stat_add[A_INT] += o_ptr->pval;
3809 if (have_flag(flgs, TR_WIS)) p_ptr->stat_add[A_WIS] += o_ptr->pval;
3810 if (have_flag(flgs, TR_DEX)) p_ptr->stat_add[A_DEX] += o_ptr->pval;
3811 if (have_flag(flgs, TR_CON)) p_ptr->stat_add[A_CON] += o_ptr->pval;
3812 if (have_flag(flgs, TR_CHR)) p_ptr->stat_add[A_CHR] += o_ptr->pval;
3814 if (have_flag(flgs, TR_MAGIC_MASTERY)) p_ptr->skill_dev += 8*o_ptr->pval;
3816 /* Affect stealth */
3817 if (have_flag(flgs, TR_STEALTH)) p_ptr->skill_stl += o_ptr->pval;
3819 /* Affect searching ability (factor of five) */
3820 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_srh += (o_ptr->pval * 5);
3822 /* Affect searching frequency (factor of five) */
3823 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_fos += (o_ptr->pval * 5);
3825 /* Affect infravision */
3826 if (have_flag(flgs, TR_INFRA)) p_ptr->see_infra += o_ptr->pval;
3828 /* Affect digging (factor of 20) */
3829 if (have_flag(flgs, TR_TUNNEL)) p_ptr->skill_dig += (o_ptr->pval * 20);
3832 if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
3835 if (have_flag(flgs, TR_BLOWS))
3837 if((i == INVEN_RARM || i == INVEN_RIGHT) && !p_ptr->ryoute) extra_blows[0] += o_ptr->pval;
3838 else if((i == INVEN_LARM || i == INVEN_LEFT) && !p_ptr->ryoute) extra_blows[1] += o_ptr->pval;
3839 else {extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval;}
3842 /* Hack -- cause earthquakes */
3843 if (have_flag(flgs, TR_IMPACT)) p_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
3846 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
3849 if (have_flag(flgs, TR_AGGRAVATE)) p_ptr->cursed |= TRC_AGGRAVATE;
3850 if (have_flag(flgs, TR_DRAIN_EXP)) p_ptr->cursed |= TRC_DRAIN_EXP;
3851 if (have_flag(flgs, TR_TY_CURSE)) p_ptr->cursed |= TRC_TY_CURSE;
3852 if (have_flag(flgs, TR_DEC_MANA)) p_ptr->dec_mana = TRUE;
3853 if (have_flag(flgs, TR_BLESSED)) p_ptr->bless_blade = TRUE;
3854 if (have_flag(flgs, TR_XTRA_MIGHT)) p_ptr->xtra_might = TRUE;
3855 if (have_flag(flgs, TR_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
3856 if (have_flag(flgs, TR_REGEN)) p_ptr->regenerate = TRUE;
3857 if (have_flag(flgs, TR_TELEPATHY)) p_ptr->telepathy = TRUE;
3858 if (have_flag(flgs, TR_ESP_ANIMAL)) p_ptr->esp_animal = TRUE;
3859 if (have_flag(flgs, TR_ESP_UNDEAD)) p_ptr->esp_undead = TRUE;
3860 if (have_flag(flgs, TR_ESP_DEMON)) p_ptr->esp_demon = TRUE;
3861 if (have_flag(flgs, TR_ESP_ORC)) p_ptr->esp_orc = TRUE;
3862 if (have_flag(flgs, TR_ESP_TROLL)) p_ptr->esp_troll = TRUE;
3863 if (have_flag(flgs, TR_ESP_GIANT)) p_ptr->esp_giant = TRUE;
3864 if (have_flag(flgs, TR_ESP_DRAGON)) p_ptr->esp_dragon = TRUE;
3865 if (have_flag(flgs, TR_ESP_HUMAN)) p_ptr->esp_human = TRUE;
3866 if (have_flag(flgs, TR_ESP_EVIL)) p_ptr->esp_evil = TRUE;
3867 if (have_flag(flgs, TR_ESP_GOOD)) p_ptr->esp_good = TRUE;
3868 if (have_flag(flgs, TR_ESP_NONLIVING)) p_ptr->esp_nonliving = TRUE;
3869 if (have_flag(flgs, TR_ESP_UNIQUE)) p_ptr->esp_unique = TRUE;
3871 if (have_flag(flgs, TR_SEE_INVIS)) p_ptr->see_inv = TRUE;
3872 if (have_flag(flgs, TR_FEATHER)) p_ptr->ffall = TRUE;
3873 if (have_flag(flgs, TR_FREE_ACT)) p_ptr->free_act = TRUE;
3874 if (have_flag(flgs, TR_HOLD_LIFE)) p_ptr->hold_life = TRUE;
3875 if (have_flag(flgs, TR_WARNING)){
3876 if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription),'$')))
3877 p_ptr->warning = TRUE;
3880 if (have_flag(flgs, TR_TELEPORT))
3882 if (cursed_p(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
3885 cptr insc = quark_str(o_ptr->inscription);
3887 if (o_ptr->inscription && my_strchr(insc, '.'))
3890 * {.} will stop random teleportation.
3895 /* Controlled random teleportation */
3896 p_ptr->cursed |= TRC_TELEPORT_SELF;
3901 /* Immunity flags */
3902 if (have_flag(flgs, TR_IM_FIRE)) p_ptr->immune_fire = TRUE;
3903 if (have_flag(flgs, TR_IM_ACID)) p_ptr->immune_acid = TRUE;
3904 if (have_flag(flgs, TR_IM_COLD)) p_ptr->immune_cold = TRUE;
3905 if (have_flag(flgs, TR_IM_ELEC)) p_ptr->immune_elec = TRUE;
3907 /* Resistance flags */
3908 if (have_flag(flgs, TR_RES_ACID)) p_ptr->resist_acid = TRUE;
3909 if (have_flag(flgs, TR_RES_ELEC)) p_ptr->resist_elec = TRUE;
3910 if (have_flag(flgs, TR_RES_FIRE)) p_ptr->resist_fire = TRUE;
3911 if (have_flag(flgs, TR_RES_COLD)) p_ptr->resist_cold = TRUE;
3912 if (have_flag(flgs, TR_RES_POIS)) p_ptr->resist_pois = TRUE;
3913 if (have_flag(flgs, TR_RES_FEAR)) p_ptr->resist_fear = TRUE;
3914 if (have_flag(flgs, TR_RES_CONF)) p_ptr->resist_conf = TRUE;
3915 if (have_flag(flgs, TR_RES_SOUND)) p_ptr->resist_sound = TRUE;
3916 if (have_flag(flgs, TR_RES_LITE)) p_ptr->resist_lite = TRUE;
3917 if (have_flag(flgs, TR_RES_DARK)) p_ptr->resist_dark = TRUE;
3918 if (have_flag(flgs, TR_RES_CHAOS)) p_ptr->resist_chaos = TRUE;
3919 if (have_flag(flgs, TR_RES_DISEN)) p_ptr->resist_disen = TRUE;
3920 if (have_flag(flgs, TR_RES_SHARDS)) p_ptr->resist_shard = TRUE;
3921 if (have_flag(flgs, TR_RES_NEXUS)) p_ptr->resist_nexus = TRUE;
3922 if (have_flag(flgs, TR_RES_BLIND)) p_ptr->resist_blind = TRUE;
3923 if (have_flag(flgs, TR_RES_NETHER)) p_ptr->resist_neth = TRUE;
3925 if (have_flag(flgs, TR_REFLECT)) p_ptr->reflect = TRUE;
3926 if (have_flag(flgs, TR_SH_FIRE)) p_ptr->sh_fire = TRUE;
3927 if (have_flag(flgs, TR_SH_ELEC)) p_ptr->sh_elec = TRUE;
3928 if (have_flag(flgs, TR_SH_COLD)) p_ptr->sh_cold = TRUE;
3929 if (have_flag(flgs, TR_NO_MAGIC)) p_ptr->anti_magic = TRUE;
3930 if (have_flag(flgs, TR_NO_TELE)) p_ptr->anti_tele = TRUE;
3933 if (have_flag(flgs, TR_SUST_STR)) p_ptr->sustain_str = TRUE;
3934 if (have_flag(flgs, TR_SUST_INT)) p_ptr->sustain_int = TRUE;
3935 if (have_flag(flgs, TR_SUST_WIS)) p_ptr->sustain_wis = TRUE;
3936 if (have_flag(flgs, TR_SUST_DEX)) p_ptr->sustain_dex = TRUE;
3937 if (have_flag(flgs, TR_SUST_CON)) p_ptr->sustain_con = TRUE;
3938 if (have_flag(flgs, TR_SUST_CHR)) p_ptr->sustain_chr = TRUE;
3940 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
3941 if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
3942 if (o_ptr->name2 == EGO_RING_RES_TIME) p_ptr->resist_time = TRUE;
3943 if (o_ptr->name2 == EGO_RING_THROW) p_ptr->mighty_throw = TRUE;
3944 if (have_flag(flgs, TR_EASY_SPELL)) p_ptr->easy_spell = TRUE;
3945 if (o_ptr->name2 == EGO_AMU_FOOL) p_ptr->heavy_spell = TRUE;
3946 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
3948 if (o_ptr->curse_flags & TRC_LOW_MAGIC)
3950 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
3952 p_ptr->to_m_chance += 10;
3956 p_ptr->to_m_chance += 3;
3960 if (o_ptr->tval == TV_CAPTURE) continue;
3962 /* Modify the base armor class */
3963 p_ptr->ac += o_ptr->ac;
3965 /* The base armor class is always known */
3966 p_ptr->dis_ac += o_ptr->ac;
3968 /* Apply the bonuses to armor class */
3969 p_ptr->to_a += o_ptr->to_a;
3971 /* Apply the mental bonuses to armor class, if known */
3972 if (object_known_p(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
3974 if (o_ptr->curse_flags & TRC_LOW_MELEE)
3976 int slot = i - INVEN_RARM;
3979 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
3981 p_ptr->to_h[slot] -= 15;
3982 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 15;
3986 p_ptr->to_h[slot] -= 5;
3987 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 5;
3992 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
3994 p_ptr->to_h_b -= 15;
3995 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 15;
4000 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 5;
4005 if (o_ptr->curse_flags & TRC_LOW_AC)
4007 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
4010 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 30;
4015 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 10;
4019 /* Hack -- do not apply "weapon" bonuses */
4020 if (i == INVEN_RARM && buki_motteruka(i)) continue;
4021 if (i == INVEN_LARM && buki_motteruka(i)) continue;
4023 /* Hack -- do not apply "bow" bonuses */
4024 if (i == INVEN_BOW) continue;
4026 bonus_to_h = o_ptr->to_h;
4027 bonus_to_d = o_ptr->to_d;
4029 if (p_ptr->pclass == CLASS_NINJA)
4031 if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h+1)/2;
4032 if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d+1)/2;
4035 /* To Bow and Natural attack */
4037 /* Apply the bonuses to hit/damage */
4038 p_ptr->to_h_b += bonus_to_h;
4039 p_ptr->to_h_m += bonus_to_h;
4040 p_ptr->to_d_m += bonus_to_d;
4042 /* Apply the mental bonuses tp hit/damage, if known */
4043 if (object_known_p(o_ptr)) p_ptr->dis_to_h_b += bonus_to_h;
4046 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
4048 /* Apply the bonuses to hit/damage */
4049 p_ptr->to_h[i-INVEN_RIGHT] += bonus_to_h;
4050 p_ptr->to_d[i-INVEN_RIGHT] += bonus_to_d;
4052 /* Apply the mental bonuses tp hit/damage, if known */
4053 if (object_known_p(o_ptr))
4055 p_ptr->dis_to_h[i-INVEN_RIGHT] += bonus_to_h;
4056 p_ptr->dis_to_d[i-INVEN_RIGHT] += bonus_to_d;
4059 else if (p_ptr->migite && p_ptr->hidarite)
4061 /* Apply the bonuses to hit/damage */
4062 p_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
4063 p_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
4064 p_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d+1)/2 : bonus_to_d;
4065 p_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
4067 /* Apply the mental bonuses tp hit/damage, if known */
4068 if (object_known_p(o_ptr))
4070 p_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
4071 p_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
4072 p_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d+1)/2 : bonus_to_d;
4073 p_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
4078 /* Apply the bonuses to hit/damage */
4079 p_ptr->to_h[0] += bonus_to_h;
4080 p_ptr->to_d[0] += bonus_to_d;
4082 /* Apply the mental bonuses to hit/damage, if known */
4083 if (object_known_p(o_ptr))
4085 p_ptr->dis_to_h[0] += bonus_to_h;
4086 p_ptr->dis_to_d[0] += bonus_to_d;
4091 if (old_mighty_throw != p_ptr->mighty_throw)
4093 /* Redraw average damege display of Shuriken */
4094 p_ptr->window |= PW_INVEN;
4097 if (p_ptr->cursed & TRC_TELEPORT) p_ptr->cursed &= ~(TRC_TELEPORT_SELF);
4099 /* Monks get extra ac for armour _not worn_ */
4100 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor())
4102 if (!(inventory[INVEN_BODY].k_idx))
4104 p_ptr->to_a += (p_ptr->lev * 3) / 2;
4105 p_ptr->dis_to_a += (p_ptr->lev * 3) / 2;
4107 if (!(inventory[INVEN_OUTER].k_idx) && (p_ptr->lev > 15))
4109 p_ptr->to_a += ((p_ptr->lev - 13) / 3);
4110 p_ptr->dis_to_a += ((p_ptr->lev - 13) / 3);
4112 if (!(inventory[INVEN_LARM].k_idx) && (p_ptr->lev > 10))
4114 p_ptr->to_a += ((p_ptr->lev - 8) / 3);
4115 p_ptr->dis_to_a += ((p_ptr->lev - 8) / 3);
4117 if (!(inventory[INVEN_HEAD].k_idx) && (p_ptr->lev > 4))
4119 p_ptr->to_a += (p_ptr->lev - 2) / 3;
4120 p_ptr->dis_to_a += (p_ptr->lev -2) / 3;
4122 if (!(inventory[INVEN_HANDS].k_idx))
4124 p_ptr->to_a += (p_ptr->lev / 2);
4125 p_ptr->dis_to_a += (p_ptr->lev / 2);
4127 if (!(inventory[INVEN_FEET].k_idx))
4129 p_ptr->to_a += (p_ptr->lev / 3);
4130 p_ptr->dis_to_a += (p_ptr->lev / 3);
4132 if (p_ptr->special_defense & KAMAE_BYAKKO)
4134 p_ptr->stat_add[A_STR] += 2;
4135 p_ptr->stat_add[A_DEX] += 2;
4136 p_ptr->stat_add[A_CON] -= 3;
4138 else if (p_ptr->special_defense & KAMAE_SEIRYU)
4141 else if (p_ptr->special_defense & KAMAE_GENBU)
4143 p_ptr->stat_add[A_INT] -= 1;
4144 p_ptr->stat_add[A_WIS] -= 1;
4145 p_ptr->stat_add[A_DEX] -= 2;
4146 p_ptr->stat_add[A_CON] += 3;
4148 else if (p_ptr->special_defense & KAMAE_SUZAKU)
4150 p_ptr->stat_add[A_STR] -= 2;
4151 p_ptr->stat_add[A_INT] += 1;
4152 p_ptr->stat_add[A_WIS] += 1;
4153 p_ptr->stat_add[A_DEX] += 2;
4154 p_ptr->stat_add[A_CON] -= 2;
4158 if (p_ptr->special_defense & KATA_KOUKIJIN)
4160 for (i = 0; i < 6; i++)
4161 p_ptr->stat_add[i] += 5;
4163 p_ptr->dis_to_a -= 50;
4166 /* Hack -- aura of fire also provides light */
4167 if (p_ptr->sh_fire) p_ptr->lite = TRUE;
4169 /* Golems also get an intrinsic AC bonus */
4170 if (prace_is_(RACE_GOLEM) || prace_is_(RACE_ANDROID))
4172 p_ptr->to_a += 10 + (p_ptr->lev * 2 / 5);
4173 p_ptr->dis_to_a += 10 + (p_ptr->lev * 2 / 5);
4176 /* Calculate stats */
4177 for (i = 0; i < 6; i++)
4181 /* Extract the new "stat_use" value for the stat */
4182 top = modify_stat_value(p_ptr->stat_max[i], p_ptr->stat_add[i]);
4184 /* Notice changes */
4185 if (p_ptr->stat_top[i] != top)
4187 /* Save the new value */
4188 p_ptr->stat_top[i] = top;
4190 /* Redisplay the stats later */
4191 p_ptr->redraw |= (PR_STATS);
4194 p_ptr->window |= (PW_PLAYER);
4198 /* Extract the new "stat_use" value for the stat */
4199 use = modify_stat_value(p_ptr->stat_cur[i], p_ptr->stat_add[i]);
4201 if ((i == A_CHR) && (p_ptr->muta3 & MUT3_ILL_NORM))
4203 /* 10 to 18/90 charisma, guaranteed, based on level */
4204 if (use < 8 + 2 * p_ptr->lev)
4206 use = 8 + 2 * p_ptr->lev;
4210 /* Notice changes */
4211 if (p_ptr->stat_use[i] != use)
4213 /* Save the new value */
4214 p_ptr->stat_use[i] = use;
4216 /* Redisplay the stats later */
4217 p_ptr->redraw |= (PR_STATS);
4220 p_ptr->window |= (PW_PLAYER);
4224 /* Values: 3, 4, ..., 17 */
4225 if (use <= 18) ind = (use - 3);
4227 /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
4228 else if (use <= 18+219) ind = (15 + (use - 18) / 10);
4230 /* Range: 18/220+ */
4233 /* Notice changes */
4234 if (p_ptr->stat_ind[i] != ind)
4236 /* Save the new index */
4237 p_ptr->stat_ind[i] = ind;
4239 /* Change in CON affects Hitpoints */
4242 p_ptr->update |= (PU_HP);
4245 /* Change in INT may affect Mana/Spells */
4246 else if (i == A_INT)
4248 if (mp_ptr->spell_stat == A_INT)
4250 p_ptr->update |= (PU_MANA | PU_SPELLS);
4254 /* Change in WIS may affect Mana/Spells */
4255 else if (i == A_WIS)
4257 if (mp_ptr->spell_stat == A_WIS)
4259 p_ptr->update |= (PU_MANA | PU_SPELLS);
4263 /* Change in WIS may affect Mana/Spells */
4264 else if (i == A_CHR)
4266 if (mp_ptr->spell_stat == A_CHR)
4268 p_ptr->update |= (PU_MANA | PU_SPELLS);
4273 p_ptr->window |= (PW_PLAYER);
4278 /* Apply temporary "stun" */
4279 if (p_ptr->stun > 50)
4281 p_ptr->to_h[0] -= 20;
4282 p_ptr->to_h[1] -= 20;
4283 p_ptr->to_h_b -= 20;
4284 p_ptr->to_h_m -= 20;
4285 p_ptr->dis_to_h[0] -= 20;
4286 p_ptr->dis_to_h[1] -= 20;
4287 p_ptr->dis_to_h_b -= 20;
4288 p_ptr->to_d[0] -= 20;
4289 p_ptr->to_d[1] -= 20;
4290 p_ptr->to_d_m -= 20;
4291 p_ptr->dis_to_d[0] -= 20;
4292 p_ptr->dis_to_d[1] -= 20;
4294 else if (p_ptr->stun)
4296 p_ptr->to_h[0] -= 5;
4297 p_ptr->to_h[1] -= 5;
4300 p_ptr->dis_to_h[0] -= 5;
4301 p_ptr->dis_to_h[1] -= 5;
4302 p_ptr->dis_to_h_b -= 5;
4303 p_ptr->to_d[0] -= 5;
4304 p_ptr->to_d[1] -= 5;
4306 p_ptr->dis_to_d[0] -= 5;
4307 p_ptr->dis_to_d[1] -= 5;
4311 if (p_ptr->wraith_form)
4313 p_ptr->reflect = TRUE;
4316 /* Temporary blessing */
4320 p_ptr->dis_to_a += 5;
4321 p_ptr->to_h[0] += 10;
4322 p_ptr->to_h[1] += 10;
4323 p_ptr->to_h_b += 10;
4324 p_ptr->to_h_m += 10;
4325 p_ptr->dis_to_h[0] += 10;
4326 p_ptr->dis_to_h[1] += 10;
4327 p_ptr->dis_to_h_b += 10;
4330 if (p_ptr->magicdef)
4332 p_ptr->resist_blind = TRUE;
4333 p_ptr->resist_conf = TRUE;
4334 p_ptr->reflect = TRUE;
4335 p_ptr->free_act = TRUE;
4336 p_ptr->ffall = TRUE;
4339 /* Temporary "Hero" */
4342 p_ptr->to_h[0] += 12;
4343 p_ptr->to_h[1] += 12;
4344 p_ptr->to_h_b += 12;
4345 p_ptr->to_h_m += 12;
4346 p_ptr->dis_to_h[0] += 12;
4347 p_ptr->dis_to_h[1] += 12;
4348 p_ptr->dis_to_h_b += 12;
4351 /* Temporary "Beserk" */
4354 p_ptr->to_h[0] += 12;
4355 p_ptr->to_h[1] += 12;
4356 p_ptr->to_h_b -= 12;
4357 p_ptr->to_h_m += 12;
4358 p_ptr->to_d[0] += 3+(p_ptr->lev/5);
4359 p_ptr->to_d[1] += 3+(p_ptr->lev/5);
4360 p_ptr->to_d_m += 3+(p_ptr->lev/5);
4361 p_ptr->dis_to_h[0] += 12;
4362 p_ptr->dis_to_h[1] += 12;
4363 p_ptr->dis_to_h_b -= 12;
4364 p_ptr->dis_to_d[0] += 3+(p_ptr->lev/5);
4365 p_ptr->dis_to_d[1] += 3+(p_ptr->lev/5);
4367 p_ptr->dis_to_a -= 10;
4368 p_ptr->skill_stl -= 7;
4369 p_ptr->skill_dev -= 20;
4370 p_ptr->skill_sav -= 30;
4371 p_ptr->skill_srh -= 15;
4372 p_ptr->skill_fos -= 15;
4373 p_ptr->skill_tht -= 20;
4374 p_ptr->skill_dig += 30;
4377 /* Temporary "fast" */
4383 /* Temporary "slow" */
4389 /* Temporary "telepathy" */
4392 p_ptr->telepathy = TRUE;
4395 if (p_ptr->ele_immune)
4397 if (p_ptr->special_defense & DEFENSE_ACID)
4398 p_ptr->immune_acid = TRUE;
4399 else if (p_ptr->special_defense & DEFENSE_ELEC)
4400 p_ptr->immune_elec = TRUE;
4401 else if (p_ptr->special_defense & DEFENSE_FIRE)
4402 p_ptr->immune_fire = TRUE;
4403 else if (p_ptr->special_defense & DEFENSE_COLD)
4404 p_ptr->immune_cold = TRUE;
4407 /* Temporary see invisible */
4408 if (p_ptr->tim_invis)
4410 p_ptr->see_inv = TRUE;
4413 /* Temporary infravision boost */
4414 if (p_ptr->tim_infra)
4416 p_ptr->see_infra+=3;
4419 /* Temporary regeneration boost */
4420 if (p_ptr->tim_regen)
4422 p_ptr->regenerate = TRUE;
4425 /* Temporary levitation */
4426 if (p_ptr->tim_ffall)
4428 p_ptr->ffall = TRUE;
4431 /* Temporary reflection */
4432 if (p_ptr->tim_reflect)
4434 p_ptr->reflect = TRUE;
4437 /* Hack -- Hero/Shero -> Res fear */
4438 if (IS_HERO() || p_ptr->shero)
4440 p_ptr->resist_fear = TRUE;
4444 /* Hack -- Telepathy Change */
4445 if (p_ptr->telepathy != old_telepathy)
4447 p_ptr->update |= (PU_MONSTERS);
4450 if ((p_ptr->esp_animal != old_esp_animal) ||
4451 (p_ptr->esp_undead != old_esp_undead) ||
4452 (p_ptr->esp_demon != old_esp_demon) ||
4453 (p_ptr->esp_orc != old_esp_orc) ||
4454 (p_ptr->esp_troll != old_esp_troll) ||
4455 (p_ptr->esp_giant != old_esp_giant) ||
4456 (p_ptr->esp_dragon != old_esp_dragon) ||
4457 (p_ptr->esp_human != old_esp_human) ||
4458 (p_ptr->esp_evil != old_esp_evil) ||
4459 (p_ptr->esp_good != old_esp_good) ||
4460 (p_ptr->esp_nonliving != old_esp_nonliving) ||
4461 (p_ptr->esp_unique != old_esp_unique))
4463 p_ptr->update |= (PU_MONSTERS);
4466 /* Hack -- See Invis Change */
4467 if (p_ptr->see_inv != old_see_inv)
4469 p_ptr->update |= (PU_MONSTERS);
4472 /* Bloating slows the player down (a little) */
4473 if (p_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
4475 if (p_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
4477 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
4479 p_ptr->to_h[0] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
4480 p_ptr->dis_to_h[0] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
4483 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
4485 int penalty1, penalty2;
4486 penalty1 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_RARM].weight) / 8);
4487 penalty2 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_LARM].weight) / 8);
4488 if ((inventory[INVEN_RARM].name1 == ART_QUICKTHORN) && (inventory[INVEN_LARM].name1 == ART_TINYTHORN))
4490 penalty1 = penalty1 / 2 - 5;
4491 penalty2 = penalty2 / 2 - 5;
4494 p_ptr->dis_to_a += 10;
4498 if (penalty1 > 0) penalty1 /= 2;
4499 if (penalty2 > 0) penalty2 /= 2;
4501 else if ((inventory[INVEN_LARM].tval == TV_SWORD) && ((inventory[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (inventory[INVEN_LARM].sval == SV_WAKIZASHI)))
4503 penalty1 = MAX(0, penalty1 - 10);
4504 penalty2 = MAX(0, penalty2 - 10);
4506 if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
4508 penalty1 = MIN(0, penalty1);
4509 penalty2 = MIN(0, penalty2);
4511 p_ptr->dis_to_a += 10;
4515 if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
4517 if ((inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
4520 if (inventory[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
4521 if (inventory[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
4522 p_ptr->to_h[0] -= penalty1;
4523 p_ptr->to_h[1] -= penalty2;
4524 p_ptr->dis_to_h[0] -= penalty1;
4525 p_ptr->dis_to_h[1] -= penalty2;
4528 /* Extract the current weight (in tenth pounds) */
4529 j = p_ptr->total_weight;
4531 /* Extract the "weight limit" (in tenth pounds) */
4536 int speed = m_list[p_ptr->riding].mspeed;
4537 if (m_list[p_ptr->riding].mspeed > 110)
4539 new_speed = 110 + (s16b)((speed - 110) * (p_ptr->skill_exp[GINOU_RIDING] * 3 + p_ptr->lev * 160L - 10000L) / (22000L));
4540 if (new_speed < 110) new_speed = 110;
4547 += (p_ptr->skill_exp[GINOU_RIDING] + p_ptr->lev *160L)/3200;
4548 if (m_list[p_ptr->riding].fast) new_speed += 10;
4549 if (m_list[p_ptr->riding].slow) new_speed -= 10;
4550 if (r_info[m_list[p_ptr->riding].r_idx].flags7 & RF7_CAN_FLY) p_ptr->ffall = TRUE;
4551 if (r_info[m_list[p_ptr->riding].r_idx].flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
4553 if (p_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED) j += (p_ptr->wt * 3 * (RIDING_EXP_SKILLED - p_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
4555 i = 3000 + r_info[m_list[p_ptr->riding].r_idx].level * 50;
4558 /* XXX XXX XXX Apply "encumbrance" from weight */
4559 if (j > i/2) new_speed -= ((j - (i/2)) / (i / 10));
4561 /* Searching slows the player down */
4562 if (p_ptr->action == ACTION_SEARCH) new_speed -= 10;
4564 /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
4565 p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
4566 p_ptr->to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4567 p_ptr->to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4568 p_ptr->to_d_m += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4569 p_ptr->to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4570 p_ptr->to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4571 p_ptr->to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4572 p_ptr->to_h_m += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4573 p_ptr->to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4574 p_ptr->to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4575 p_ptr->to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4576 p_ptr->to_h_m += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4578 /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
4579 p_ptr->dis_to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
4580 p_ptr->dis_to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4581 p_ptr->dis_to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
4582 p_ptr->dis_to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4583 p_ptr->dis_to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4584 p_ptr->dis_to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
4585 p_ptr->dis_to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4586 p_ptr->dis_to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4587 p_ptr->dis_to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
4590 /* Obtain the "hold" value */
4591 hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
4594 /* Examine the "current bow" */
4595 o_ptr = &inventory[INVEN_BOW];
4598 /* Assume not heavy */
4599 p_ptr->heavy_shoot = FALSE;
4601 /* It is hard to carholdry a heavy bow */
4602 if (hold < o_ptr->weight / 10)
4604 /* Hard to wield a heavy bow */
4605 p_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
4606 p_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
4609 p_ptr->heavy_shoot = TRUE;
4613 /* Compute "extra shots" if needed */
4616 /* Analyze the launcher */
4617 switch (o_ptr->sval)
4621 p_ptr->tval_ammo = TV_SHOT;
4629 p_ptr->tval_ammo = TV_ARROW;
4636 p_ptr->tval_ammo = TV_BOLT;
4641 p_ptr->tval_ammo = TV_NO_AMMO;
4646 /* Apply special flags */
4647 if (o_ptr->k_idx && !p_ptr->heavy_shoot)
4650 p_ptr->num_fire += (extra_shots * 100);
4652 /* Hack -- Rangers love Bows */
4653 if ((p_ptr->pclass == CLASS_RANGER) &&
4654 (p_ptr->tval_ammo == TV_ARROW))
4656 p_ptr->num_fire += (p_ptr->lev * 4);
4659 if ((p_ptr->pclass == CLASS_CAVALRY) &&
4660 (p_ptr->tval_ammo == TV_ARROW))
4662 p_ptr->num_fire += (p_ptr->lev * 3);
4665 if (p_ptr->pclass == CLASS_ARCHER)
4667 if (p_ptr->tval_ammo == TV_ARROW)
4668 p_ptr->num_fire += ((p_ptr->lev * 5)+50);
4669 else if ((p_ptr->tval_ammo == TV_BOLT) || (p_ptr->tval_ammo == TV_SHOT))
4670 p_ptr->num_fire += (p_ptr->lev * 4);
4674 * Addendum -- also "Reward" high level warriors,
4675 * with _any_ missile weapon -- TY
4677 if (p_ptr->pclass == CLASS_WARRIOR &&
4678 (p_ptr->tval_ammo <= TV_BOLT) &&
4679 (p_ptr->tval_ammo >= TV_SHOT))
4681 p_ptr->num_fire += (p_ptr->lev * 2);
4683 if ((p_ptr->pclass == CLASS_ROGUE) &&
4684 (p_ptr->tval_ammo == TV_SHOT))
4686 p_ptr->num_fire += (p_ptr->lev * 4);
4694 for(i = 0 ; i < 2 ; i++)
4696 /* Examine the "main weapon" */
4697 o_ptr = &inventory[INVEN_RARM+i];
4699 object_flags(o_ptr, flgs);
4701 /* Assume not heavy */
4702 p_ptr->heavy_wield[i] = FALSE;
4703 p_ptr->icky_wield[i] = FALSE;
4704 p_ptr->riding_wield[i] = FALSE;
4706 if (!buki_motteruka(INVEN_RARM+i)) {p_ptr->num_blow[i]=1;continue;}
4707 /* It is hard to hold a heavy weapon */
4708 if (hold < o_ptr->weight / 10)
4710 /* Hard to wield a heavy weapon */
4711 p_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
4712 p_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
4715 p_ptr->heavy_wield[i] = TRUE;
4717 else if (p_ptr->ryoute && (hold < o_ptr->weight/5)) omoi = TRUE;
4719 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
4722 p_ptr->dis_to_a += 5;
4725 /* Normal weapons */
4726 if (o_ptr->k_idx && !p_ptr->heavy_wield[i])
4728 int str_index, dex_index;
4730 int num = 0, wgt = 0, mul = 0, div = 0;
4732 /* Analyze the class */
4733 switch (p_ptr->pclass)
4737 num = 6; wgt = 70; mul = 5; break;
4740 case CLASS_BERSERKER:
4741 num = 6; wgt = 70; mul = 7; break;
4745 case CLASS_HIGH_MAGE:
4746 case CLASS_BLUE_MAGE:
4747 num = 3; wgt = 100; mul = 2; break;
4749 /* Priest, Mindcrafter */
4751 case CLASS_MAGIC_EATER:
4752 case CLASS_MINDCRAFTER:
4753 num = 5; wgt = 100; mul = 3; break;
4757 num = 5; wgt = 40; mul = 3; break;
4761 num = 5; wgt = 70; mul = 4; break;
4766 num = 5; wgt = 70; mul = 4; break;
4770 num = 5; wgt = 150; mul = 5; break;
4773 case CLASS_WARRIOR_MAGE:
4774 case CLASS_RED_MAGE:
4775 num = 5; wgt = 70; mul = 3; break;
4778 case CLASS_CHAOS_WARRIOR:
4779 num = 5; wgt = 70; mul = 4; break;
4783 num = 5; wgt = 60; mul = 3; break;
4787 num = 4; wgt = 100; mul = 3; break;
4790 case CLASS_IMITATOR:
4791 num = 5; wgt = 70; mul = 4; break;
4794 case CLASS_BEASTMASTER:
4795 num = 5; wgt = 70; mul = 3; break;
4798 if ((p_ptr->riding) && (have_flag(flgs, TR_RIDING))) {num = 5; wgt = 70; mul = 4;}
4799 else {num = 5; wgt = 100; mul = 3;}
4803 case CLASS_SORCERER:
4804 num = 1; wgt = 1; mul = 1; break;
4806 /* Archer, Magic eater */
4809 num = 4; wgt = 70; mul = 2; break;
4812 case CLASS_FORCETRAINER:
4813 num = 4; wgt = 60; mul = 2; break;
4816 case CLASS_MIRROR_MASTER:
4817 num = 3; wgt = 100; mul = 3; break;
4821 num = 4; wgt = 20; mul = 1; break;
4824 /* Enforce a minimum "weight" (tenth pounds) */
4825 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
4827 /* Access the strength vs weight */
4828 str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * mul / div);
4830 if (p_ptr->ryoute && !omoi) str_index++;
4831 if (p_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index-1);
4834 if (str_index > 11) str_index = 11;
4836 /* Index by dexterity */
4837 dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]);
4840 if (dex_index > 11) dex_index = 11;
4842 /* Use the blows table */
4843 p_ptr->num_blow[i] = blows_table[str_index][dex_index];
4846 if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = num;
4848 /* Add in the "bonus blows" */
4849 p_ptr->num_blow[i] += extra_blows[i];
4852 if (p_ptr->pclass == CLASS_WARRIOR) p_ptr->num_blow[i] += (p_ptr->lev / 40);
4853 else if (p_ptr->pclass == CLASS_BERSERKER)
4855 p_ptr->num_blow[i] += (p_ptr->lev / 23);
4857 else if ((p_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (p_ptr->stat_ind[A_DEX] >= 30)) p_ptr->num_blow[i] ++;
4859 if (p_ptr->special_defense & KATA_FUUJIN) p_ptr->num_blow[i] -= 1;
4861 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) p_ptr->num_blow[i] = 1;
4864 /* Require at least one blow */
4865 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
4867 /* Boost digging skill by weapon weight */
4868 p_ptr->skill_dig += (o_ptr->weight / 10);
4872 /* Priest weapon penalty for non-blessed edged weapons */
4873 if ((p_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
4874 ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
4876 /* Reduce the real bonuses */
4877 p_ptr->to_h[i] -= 2;
4878 p_ptr->to_d[i] -= 2;
4880 /* Reduce the mental bonuses */
4881 p_ptr->dis_to_h[i] -= 2;
4882 p_ptr->dis_to_d[i] -= 2;
4885 p_ptr->icky_wield[i] = TRUE;
4887 else if (p_ptr->pclass == CLASS_BERSERKER)
4889 p_ptr->to_h[i] += p_ptr->lev/5;
4890 p_ptr->to_d[i] += p_ptr->lev/6;
4891 p_ptr->dis_to_h[i] += p_ptr->lev/5;
4892 p_ptr->dis_to_d[i] += p_ptr->lev/6;
4893 if (!p_ptr->hidarite || p_ptr->ryoute)
4895 p_ptr->to_h[i] += p_ptr->lev/5;
4896 p_ptr->to_d[i] += p_ptr->lev/6;
4897 p_ptr->dis_to_h[i] += p_ptr->lev/5;
4898 p_ptr->dis_to_d[i] += p_ptr->lev/6;
4901 else if (p_ptr->pclass == CLASS_SORCERER)
4903 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
4905 /* Reduce the real bonuses */
4906 p_ptr->to_h[i] -= 200;
4907 p_ptr->to_d[i] -= 200;
4909 /* Reduce the mental bonuses */
4910 p_ptr->dis_to_h[i] -= 200;
4911 p_ptr->dis_to_d[i] -= 200;
4914 p_ptr->icky_wield[i] = TRUE;
4918 /* Reduce the real bonuses */
4919 p_ptr->to_h[i] -= 30;
4920 p_ptr->to_d[i] -= 10;
4922 /* Reduce the mental bonuses */
4923 p_ptr->dis_to_h[i] -= 30;
4924 p_ptr->dis_to_d[i] -= 10;
4929 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
4931 p_ptr->to_h[i] +=15;
4932 p_ptr->dis_to_h[i] +=15;
4933 p_ptr->to_dd[i] += 2;
4935 else if (!(have_flag(flgs, TR_RIDING)))
4938 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
4944 penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
4946 if (penalty < 30) penalty = 30;
4948 p_ptr->to_h[i] -= penalty;
4949 p_ptr->dis_to_h[i] -= penalty;
4952 p_ptr->riding_wield[i] = TRUE;
4961 p_ptr->riding_ryoute = FALSE;
4962 if (p_ptr->ryoute || (empty_hands(FALSE) == EMPTY_HAND_NONE)) p_ptr->riding_ryoute = TRUE;
4964 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
4966 if (p_ptr->tval_ammo != TV_ARROW) penalty = 5;
4970 penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
4972 if (penalty < 30) penalty = 30;
4974 if (p_ptr->tval_ammo == TV_BOLT) penalty *= 2;
4975 p_ptr->to_h_b -= penalty;
4976 p_ptr->dis_to_h_b -= penalty;
4979 /* Different calculation for monks with empty hands */
4980 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
4982 int blow_base = p_ptr->lev + adj_dex_blow[p_ptr->stat_ind[A_DEX]];
4983 p_ptr->num_blow[0] = 0;
4985 if (p_ptr->pclass == CLASS_FORCETRAINER)
4987 if (blow_base > 18) p_ptr->num_blow[0]++;
4988 if (blow_base > 31) p_ptr->num_blow[0]++;
4989 if (blow_base > 44) p_ptr->num_blow[0]++;
4990 if (blow_base > 58) p_ptr->num_blow[0]++;
4991 if (p_ptr->magic_num1[0])
4993 p_ptr->to_d[0] += (p_ptr->magic_num1[0]/5);
4994 p_ptr->dis_to_d[0] += (p_ptr->magic_num1[0]/5);
4999 if (blow_base > 12) p_ptr->num_blow[0]++;
5000 if (blow_base > 22) p_ptr->num_blow[0]++;
5001 if (blow_base > 31) p_ptr->num_blow[0]++;
5002 if (blow_base > 39) p_ptr->num_blow[0]++;
5003 if (blow_base > 46) p_ptr->num_blow[0]++;
5004 if (blow_base > 53) p_ptr->num_blow[0]++;
5005 if (blow_base > 59) p_ptr->num_blow[0]++;
5008 if (heavy_armor() && (p_ptr->pclass != CLASS_BERSERKER))
5009 p_ptr->num_blow[0] /= 2;
5012 p_ptr->to_h[0] += (p_ptr->lev / 3);
5013 p_ptr->dis_to_h[0] += (p_ptr->lev / 3);
5015 p_ptr->to_d[0] += (p_ptr->lev / 6);
5016 p_ptr->dis_to_d[0] += (p_ptr->lev / 6);
5019 if (p_ptr->special_defense & KAMAE_BYAKKO)
5022 p_ptr->dis_to_a -= 40;
5025 else if (p_ptr->special_defense & KAMAE_SEIRYU)
5028 p_ptr->dis_to_a -= 50;
5029 p_ptr->resist_acid = TRUE;
5030 p_ptr->resist_fire = TRUE;
5031 p_ptr->resist_elec = TRUE;
5032 p_ptr->resist_cold = TRUE;
5033 p_ptr->resist_pois = TRUE;
5034 p_ptr->sh_fire = TRUE;
5035 p_ptr->sh_elec = TRUE;
5036 p_ptr->sh_cold = TRUE;
5037 p_ptr->ffall = TRUE;
5039 else if (p_ptr->special_defense & KAMAE_GENBU)
5041 p_ptr->to_a += (p_ptr->lev*p_ptr->lev)/50;
5042 p_ptr->dis_to_a += (p_ptr->lev*p_ptr->lev)/50;
5043 p_ptr->reflect = TRUE;
5044 p_ptr->num_blow[0] -= 2;
5045 if ((p_ptr->pclass == CLASS_MONK) && (p_ptr->lev > 42)) p_ptr->num_blow[0]--;
5046 if (p_ptr->num_blow[0] < 0) p_ptr->num_blow[0] = 0;
5048 else if (p_ptr->special_defense & KAMAE_SUZAKU)
5050 p_ptr->to_h[0] -= (p_ptr->lev / 3);
5051 p_ptr->to_d[0] -= (p_ptr->lev / 6);
5053 p_ptr->dis_to_h[0] -= (p_ptr->lev / 3);
5054 p_ptr->dis_to_d[0] -= (p_ptr->lev / 6);
5055 p_ptr->num_blow[0] /= 2;
5056 p_ptr->ffall = TRUE;
5059 p_ptr->num_blow[0] += 1+extra_blows[0];
5062 monk_armour_aux = FALSE;
5066 monk_armour_aux = TRUE;
5069 for (i = 0 ; i < 2 ; i++)
5071 if (buki_motteruka(INVEN_RARM+i))
5073 int tval = inventory[INVEN_RARM+i].tval - TV_WEAPON_BEGIN;
5074 int sval = inventory[INVEN_RARM+i].sval;
5076 p_ptr->to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
5077 p_ptr->dis_to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
5078 if ((p_ptr->pclass == CLASS_MONK) && !(s_info[CLASS_MONK].w_max[tval][sval]))
5080 p_ptr->to_h[i] -= 40;
5081 p_ptr->dis_to_h[i] -= 40;
5082 p_ptr->icky_wield[i] = TRUE;
5084 else if ((p_ptr->pclass == CLASS_FORCETRAINER) && !(s_info[CLASS_FORCETRAINER].w_max[tval][sval]))
5086 p_ptr->to_h[i] -= 40;
5087 p_ptr->dis_to_h[i] -= 40;
5088 p_ptr->icky_wield[i] = TRUE;
5090 else if (p_ptr->pclass == CLASS_NINJA)
5092 if ((s_info[CLASS_NINJA].w_max[tval][sval] <= WEAPON_EXP_BEGINNER) || (inventory[INVEN_LARM-i].tval == TV_SHIELD))
5094 p_ptr->to_h[i] -= 40;
5095 p_ptr->dis_to_h[i] -= 40;
5096 p_ptr->icky_wield[i] = TRUE;
5097 p_ptr->num_blow[i] /= 2;
5098 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
5104 /* Maximum speed is (+99). (internally it's 110 + 99) */
5105 /* Temporary lightspeed forces to be maximum speed */
5106 if ((p_ptr->lightspeed && !p_ptr->riding) || (new_speed > 209))
5111 /* Minimum speed is (-99). (internally it's 110 - 99) */
5112 if (new_speed < 11) new_speed = 11;
5114 /* Display the speed (if needed) */
5115 if (p_ptr->pspeed != (byte)new_speed)
5117 p_ptr->pspeed = (byte)new_speed;
5118 p_ptr->redraw |= (PR_SPEED);
5123 if (p_ptr->to_a > (0 - p_ptr->ac))
5124 p_ptr->to_a = 0 - p_ptr->ac;
5125 if (p_ptr->dis_to_a > (0 - p_ptr->dis_ac))
5126 p_ptr->dis_to_a = 0 - p_ptr->dis_ac;
5129 /* Redraw armor (if needed) */
5130 if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
5133 p_ptr->redraw |= (PR_ARMOR);
5136 p_ptr->window |= (PW_PLAYER);
5140 if (p_ptr->ryoute && !omoi)
5142 int bonus_to_h=0, bonus_to_d=0;
5143 bonus_to_d = ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128)/2;
5144 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);
5146 p_ptr->to_h[0] += MAX(bonus_to_h,1);
5147 p_ptr->dis_to_h[0] += MAX(bonus_to_h,1);
5148 p_ptr->to_d[0] += MAX(bonus_to_d,1);
5149 p_ptr->dis_to_d[0] += MAX(bonus_to_d,1);
5152 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(TRUE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))) p_ptr->ryoute = FALSE;
5154 /* Affect Skill -- stealth (bonus one) */
5155 p_ptr->skill_stl += 1;
5157 if (IS_TIM_STEALTH()) p_ptr->skill_stl += 99;
5159 /* Affect Skill -- disarming (DEX and INT) */
5160 p_ptr->skill_dis += adj_dex_dis[p_ptr->stat_ind[A_DEX]];
5161 p_ptr->skill_dis += adj_int_dis[p_ptr->stat_ind[A_INT]];
5163 /* Affect Skill -- magic devices (INT) */
5164 p_ptr->skill_dev += adj_int_dev[p_ptr->stat_ind[A_INT]];
5166 /* Affect Skill -- saving throw (WIS) */
5167 p_ptr->skill_sav += adj_wis_sav[p_ptr->stat_ind[A_WIS]];
5169 /* Affect Skill -- digging (STR) */
5170 p_ptr->skill_dig += adj_str_dig[p_ptr->stat_ind[A_STR]];
5172 /* Affect Skill -- disarming (Level, by Class) */
5173 p_ptr->skill_dis += ((cp_ptr->x_dis * p_ptr->lev / 10) + (ap_ptr->a_dis * p_ptr->lev / 50));
5175 /* Affect Skill -- magic devices (Level, by Class) */
5176 p_ptr->skill_dev += ((cp_ptr->x_dev * p_ptr->lev / 10) + (ap_ptr->a_dev * p_ptr->lev / 50));
5178 /* Affect Skill -- saving throw (Level, by Class) */
5179 p_ptr->skill_sav += ((cp_ptr->x_sav * p_ptr->lev / 10) + (ap_ptr->a_sav * p_ptr->lev / 50));
5181 /* Affect Skill -- stealth (Level, by Class) */
5182 p_ptr->skill_stl += (cp_ptr->x_stl * p_ptr->lev / 10);
5184 /* Affect Skill -- search ability (Level, by Class) */
5185 p_ptr->skill_srh += (cp_ptr->x_srh * p_ptr->lev / 10);
5187 /* Affect Skill -- search frequency (Level, by Class) */
5188 p_ptr->skill_fos += (cp_ptr->x_fos * p_ptr->lev / 10);
5190 /* Affect Skill -- combat (normal) (Level, by Class) */
5191 p_ptr->skill_thn += ((cp_ptr->x_thn * p_ptr->lev / 10) + (ap_ptr->a_thn * p_ptr->lev / 50));
5193 /* Affect Skill -- combat (shooting) (Level, by Class) */
5194 p_ptr->skill_thb += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
5196 /* Affect Skill -- combat (throwing) (Level, by Class) */
5197 p_ptr->skill_tht += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
5200 if ((prace_is_(RACE_S_FAIRY)) && (p_ptr->pseikaku != SEIKAKU_SEXY) && (p_ptr->cursed & TRC_AGGRAVATE))
5202 p_ptr->cursed &= ~(TRC_AGGRAVATE);
5203 p_ptr->skill_stl = MIN(p_ptr->skill_stl - 3, (p_ptr->skill_stl + 2) / 2);
5206 /* Limit Skill -- stealth from 0 to 30 */
5207 if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
5208 if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;
5210 /* Limit Skill -- digging from 1 up */
5211 if (p_ptr->skill_dig < 1) p_ptr->skill_dig = 1;
5213 if (p_ptr->anti_magic && (p_ptr->skill_sav < (90 + p_ptr->lev))) p_ptr->skill_sav = 90 + p_ptr->lev;
5215 if (p_ptr->tsubureru) p_ptr->skill_sav = 10;
5217 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;
5219 if (down_saving) p_ptr->skill_sav /= 2;
5221 /* Hack -- Each elemental immunity includes resistance */
5222 if (p_ptr->immune_acid) p_ptr->resist_acid = TRUE;
5223 if (p_ptr->immune_elec) p_ptr->resist_elec = TRUE;
5224 if (p_ptr->immune_fire) p_ptr->resist_fire = TRUE;
5225 if (p_ptr->immune_cold) p_ptr->resist_cold = TRUE;
5227 /* Hack -- handle "xtra" mode */
5228 if (character_xtra) return;
5230 /* Take note when "heavy bow" changes */
5231 if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
5234 if (p_ptr->heavy_shoot)
5237 msg_print("¤³¤ó¤Ê½Å¤¤µÝ¤òÁõÈ÷¤·¤Æ¤¤¤ë¤Î¤ÏÂçÊѤÀ¡£");
5239 msg_print("You have trouble wielding such a heavy bow.");
5243 else if (inventory[INVEN_BOW].k_idx)
5246 msg_print("¤³¤ÎµÝ¤Ê¤éÁõÈ÷¤·¤Æ¤¤¤Æ¤â¿É¤¯¤Ê¤¤¡£");
5248 msg_print("You have no trouble wielding your bow.");
5255 msg_print("½Å¤¤µÝ¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤ÆÂΤ¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5257 msg_print("You feel relieved to put down your heavy bow.");
5263 p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
5266 for(i = 0 ; i < 2 ; i++)
5268 /* Take note when "heavy weapon" changes */
5269 if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
5272 if (p_ptr->heavy_wield[i])
5275 msg_print("¤³¤ó¤Ê½Å¤¤Éð´ï¤òÁõÈ÷¤·¤Æ¤¤¤ë¤Î¤ÏÂçÊѤÀ¡£");
5277 msg_print("You have trouble wielding such a heavy weapon.");
5281 else if (buki_motteruka(INVEN_RARM+i))
5284 msg_print("¤³¤ì¤Ê¤éÁõÈ÷¤·¤Æ¤¤¤Æ¤â¿É¤¯¤Ê¤¤¡£");
5286 msg_print("You have no trouble wielding your weapon.");
5290 else if (p_ptr->heavy_wield[1-i])
5293 msg_print("¤Þ¤ÀÉð´ï¤¬½Å¤¤¡£");
5295 msg_print("You have still trouble wielding a heavy weapon.");
5302 msg_print("½Å¤¤Éð´ï¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤ÆÂΤ¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5304 msg_print("You feel relieved to put down your heavy weapon.");
5310 p_ptr->old_heavy_wield[i] = p_ptr->heavy_wield[i];
5313 /* Take note when "heavy weapon" changes */
5314 if (p_ptr->old_riding_wield[i] != p_ptr->riding_wield[i])
5317 if (p_ptr->riding_wield[i])
5320 msg_print("¤³¤ÎÉð´ï¤Ï¾èÇÏÃæ¤Ë»È¤¦¤Ë¤Ï¤à¤«¤Ê¤¤¤è¤¦¤À¡£");
5322 msg_print("This weapon is not suitable for use while riding.");
5326 else if (!p_ptr->riding)
5329 msg_print("¤³¤ÎÉð´ï¤ÏÅÌÊâ¤Ç»È¤¤¤ä¤¹¤¤¡£");
5331 msg_print("This weapon was not suitable for use while riding.");
5335 else if (buki_motteruka(INVEN_RARM+i))
5338 msg_print("¤³¤ì¤Ê¤é¾èÇÏÃæ¤Ë¤Ô¤Ã¤¿¤ê¤À¡£");
5340 msg_print("This weapon is suitable for use while riding.");
5345 p_ptr->old_riding_wield[i] = p_ptr->riding_wield[i];
5348 /* Take note when "illegal weapon" changes */
5349 if (p_ptr->old_icky_wield[i] != p_ptr->icky_wield[i])
5352 if (p_ptr->icky_wield[i])
5355 msg_print("º£¤ÎÁõÈ÷¤Ï¤É¤¦¤â¼«Ê¬¤Ë¤Õ¤µ¤ï¤·¤¯¤Ê¤¤µ¤¤¬¤¹¤ë¡£");
5357 msg_print("You do not feel comfortable with your weapon.");
5361 chg_virtue(V_FAITH, -1);
5364 else if (buki_motteruka(INVEN_RARM+i))
5367 msg_print("º£¤ÎÁõÈ÷¤Ï¼«Ê¬¤Ë¤Õ¤µ¤ï¤·¤¤µ¤¤¬¤¹¤ë¡£");
5369 msg_print("You feel comfortable with your weapon.");
5376 msg_print("ÁõÈ÷¤ò¤Ï¤º¤·¤¿¤é¿ïʬ¤Èµ¤¤¬³Ú¤Ë¤Ê¤Ã¤¿¡£");
5378 msg_print("You feel more comfortable after removing your weapon.");
5384 p_ptr->old_icky_wield[i] = p_ptr->icky_wield[i];
5388 if (p_ptr->riding && (p_ptr->old_riding_ryoute != p_ptr->riding_ryoute))
5391 if (p_ptr->riding_ryoute)
5394 msg_print("ξ¼ê¤¬¤Õ¤µ¤¬¤Ã¤Æ¤¤¤ÆÇϤòÁà¤ì¤Ê¤¤¡£");
5396 msg_print("You are using both hand for fighting, and you can't control a riding pet.");
5402 msg_print("¼ê¤¬¶õ¤¤¤ÆÇϤòÁà¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
5404 msg_print("You began to control riding pet with one hand.");
5408 p_ptr->old_riding_ryoute = p_ptr->riding_ryoute;
5411 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && (monk_armour_aux != monk_notify_aux))
5416 msg_print("ÁõÈ÷¤¬½Å¤¯¤Æ¥Ð¥é¥ó¥¹¤ò¼è¤ì¤Ê¤¤¡£");
5418 msg_print("The weight of your armor disrupts your balance.");
5423 chg_virtue(V_HARMONY, -1);
5428 msg_print("¥Ð¥é¥ó¥¹¤¬¤È¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
5430 msg_print("You regain your balance.");
5433 monk_notify_aux = monk_armour_aux;
5437 p_ptr->align = friend_align;
5439 /* Determine player alignment */
5440 for (i = 0; i < 8; i++)
5442 if ((p_ptr->vir_types[i] == V_HARMONY) || (p_ptr->vir_types[i] == V_NATURE))
5447 else if (p_ptr->vir_types[i] == V_UNLIFE) p_ptr->align -= p_ptr->virtues[i];
5448 else if (p_ptr->vir_types[i] == V_JUSTICE) p_ptr->align += (p_ptr->virtues[i]*2);
5449 else if (p_ptr->vir_types[i] != V_CHANCE) p_ptr->align += p_ptr->virtues[i];
5451 if ((inventory[INVEN_RARM].name1 == ART_IRON_BALL) || (inventory[INVEN_LARM].name1 == ART_IRON_BALL)) p_ptr->align -= 1000;
5452 if (prace_is_(RACE_ANGEL)) p_ptr->align += 200;
5453 if ((prace_is_(RACE_DEMON)) || (p_ptr->mimic_form == MIMIC_DEMON_LORD) || (p_ptr->mimic_form == MIMIC_DEMON)) p_ptr->align -= 200;
5457 if (p_ptr->align > 0)
5459 p_ptr->align -= (p_ptr->virtues[neutral[j]]/2);
5460 if (p_ptr->align < 0) p_ptr->align = 0;
5462 else if (p_ptr->align < 0)
5464 p_ptr->align += (p_ptr->virtues[neutral[j]]/2);
5465 if (p_ptr->align > 0) p_ptr->align = 0;
5469 for (i = 0; i < INVEN_PACK; i++)
5472 if ((inventory[i].tval == TV_SORCERY_BOOK) && (inventory[i].sval == 2)) have_dd_s = TRUE;
5473 if ((inventory[i].tval == TV_TRUMP_BOOK) && (inventory[i].sval == 1)) have_dd_t = TRUE;
5475 if ((inventory[i].tval == TV_NATURE_BOOK) && (inventory[i].sval == 2)) have_sw = TRUE;
5476 if ((inventory[i].tval == TV_ENCHANT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
5478 for (this_o_idx = cave[py][px].o_idx; this_o_idx; this_o_idx = next_o_idx)
5482 /* Acquire object */
5483 o_ptr = &o_list[this_o_idx];
5485 /* Acquire next object */
5486 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;
5492 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
5493 if ((o_ptr->tval == TV_ENCHANT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
5496 if ((p_ptr->pass_wall && !p_ptr->kill_wall) || p_ptr->kabenuke || p_ptr->wraith_form) p_ptr->no_flowed = TRUE;
5498 if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER)))
5500 magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY-1][SPELL_DD_S];
5501 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5504 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)))
5506 magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP-1][SPELL_DD_T];
5507 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5510 if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER)))
5512 magic_type *s_ptr = &mp_ptr->info[REALM_NATURE-1][SPELL_SW];
5513 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5516 if (have_kabe && ((p_ptr->realm1 == REALM_ENCHANT) || (p_ptr->realm2 == REALM_ENCHANT) || (p_ptr->pclass == CLASS_SORCERER)))
5518 magic_type *s_ptr = &mp_ptr->info[REALM_ENCHANT-1][SPELL_KABE];
5519 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
5526 * Handle "p_ptr->notice"
5528 void notice_stuff(void)
5531 if (!p_ptr->notice) return;
5534 /* Actually do auto-destroy */
5535 if (p_ptr->notice & (PN_AUTODESTROY))
5537 p_ptr->notice &= ~(PN_AUTODESTROY);
5538 autopick_delayed_alter();
5541 /* Combine the pack */
5542 if (p_ptr->notice & (PN_COMBINE))
5544 p_ptr->notice &= ~(PN_COMBINE);
5548 /* Reorder the pack */
5549 if (p_ptr->notice & (PN_REORDER))
5551 p_ptr->notice &= ~(PN_REORDER);
5558 * Handle "p_ptr->update"
5560 void update_stuff(void)
5563 if (!p_ptr->update) return;
5566 if (p_ptr->update & (PU_BONUS))
5568 p_ptr->update &= ~(PU_BONUS);
5572 if (p_ptr->update & (PU_TORCH))
5574 p_ptr->update &= ~(PU_TORCH);
5578 if (p_ptr->update & (PU_HP))
5580 p_ptr->update &= ~(PU_HP);
5584 if (p_ptr->update & (PU_MANA))
5586 p_ptr->update &= ~(PU_MANA);
5590 if (p_ptr->update & (PU_SPELLS))
5592 p_ptr->update &= ~(PU_SPELLS);
5597 /* Character is not ready yet, no screen updates */
5598 if (!character_generated) return;
5601 /* Character is in "icky" mode, no screen updates */
5602 if (character_icky) return;
5605 if (p_ptr->update & (PU_UN_LITE))
5607 p_ptr->update &= ~(PU_UN_LITE);
5611 if (p_ptr->update & (PU_UN_VIEW))
5613 p_ptr->update &= ~(PU_UN_VIEW);
5617 if (p_ptr->update & (PU_VIEW))
5619 p_ptr->update &= ~(PU_VIEW);
5623 if (p_ptr->update & (PU_LITE))
5625 p_ptr->update &= ~(PU_LITE);
5630 if (p_ptr->update & (PU_FLOW))
5632 p_ptr->update &= ~(PU_FLOW);
5636 if (p_ptr->update & (PU_DISTANCE))
5638 p_ptr->update &= ~(PU_DISTANCE);
5640 /* Still need to call update_monsters(FALSE) after update_mon_lite() */
5641 /* p_ptr->update &= ~(PU_MONSTERS); */
5643 update_monsters(TRUE);
5646 if (p_ptr->update & (PU_MON_LITE))
5648 p_ptr->update &= ~(PU_MON_LITE);
5653 * Mega-Hack -- Delayed visual update
5654 * Only used if update_view(), update_lite() or update_mon_lite() was called
5656 if (p_ptr->update & (PU_DELAY_VIS))
5658 p_ptr->update &= ~(PU_DELAY_VIS);
5659 delayed_visual_update();
5662 if (p_ptr->update & (PU_MONSTERS))
5664 p_ptr->update &= ~(PU_MONSTERS);
5665 update_monsters(FALSE);
5671 * Handle "p_ptr->redraw"
5673 void redraw_stuff(void)
5676 if (!p_ptr->redraw) return;
5679 /* Character is not ready yet, no screen updates */
5680 if (!character_generated) return;
5683 /* Character is in "icky" mode, no screen updates */
5684 if (character_icky) return;
5688 /* Hack -- clear the screen */
5689 if (p_ptr->redraw & (PR_WIPE))
5691 p_ptr->redraw &= ~(PR_WIPE);
5697 if (p_ptr->redraw & (PR_MAP))
5699 p_ptr->redraw &= ~(PR_MAP);
5704 if (p_ptr->redraw & (PR_BASIC))
5706 p_ptr->redraw &= ~(PR_BASIC);
5707 p_ptr->redraw &= ~(PR_MISC | PR_TITLE | PR_STATS);
5708 p_ptr->redraw &= ~(PR_LEV | PR_EXP | PR_GOLD);
5709 p_ptr->redraw &= ~(PR_ARMOR | PR_HP | PR_MANA);
5710 p_ptr->redraw &= ~(PR_DEPTH | PR_HEALTH | PR_UHEALTH);
5716 if (p_ptr->redraw & (PR_EQUIPPY))
5718 p_ptr->redraw &= ~(PR_EQUIPPY);
5719 print_equippy(); /* To draw / delete equippy chars */
5722 if (p_ptr->redraw & (PR_MISC))
5724 p_ptr->redraw &= ~(PR_MISC);
5725 prt_field(rp_ptr->title, ROW_RACE, COL_RACE);
5726 /* prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
5730 if (p_ptr->redraw & (PR_TITLE))
5732 p_ptr->redraw &= ~(PR_TITLE);
5736 if (p_ptr->redraw & (PR_LEV))
5738 p_ptr->redraw &= ~(PR_LEV);
5742 if (p_ptr->redraw & (PR_EXP))
5744 p_ptr->redraw &= ~(PR_EXP);
5748 if (p_ptr->redraw & (PR_STATS))
5750 p_ptr->redraw &= ~(PR_STATS);
5759 if (p_ptr->redraw & (PR_STATUS))
5761 p_ptr->redraw &= ~(PR_STATUS);
5765 if (p_ptr->redraw & (PR_ARMOR))
5767 p_ptr->redraw &= ~(PR_ARMOR);
5771 if (p_ptr->redraw & (PR_HP))
5773 p_ptr->redraw &= ~(PR_HP);
5777 if (p_ptr->redraw & (PR_MANA))
5779 p_ptr->redraw &= ~(PR_MANA);
5783 if (p_ptr->redraw & (PR_GOLD))
5785 p_ptr->redraw &= ~(PR_GOLD);
5789 if (p_ptr->redraw & (PR_DEPTH))
5791 p_ptr->redraw &= ~(PR_DEPTH);
5795 if (p_ptr->redraw & (PR_HEALTH))
5797 p_ptr->redraw &= ~(PR_HEALTH);
5798 health_redraw(FALSE);
5801 if (p_ptr->redraw & (PR_UHEALTH))
5803 p_ptr->redraw &= ~(PR_UHEALTH);
5804 health_redraw(TRUE);
5808 if (p_ptr->redraw & (PR_EXTRA))
5810 p_ptr->redraw &= ~(PR_EXTRA);
5811 p_ptr->redraw &= ~(PR_CUT | PR_STUN);
5812 p_ptr->redraw &= ~(PR_HUNGER);
5813 p_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_MANE | PR_STATUS);
5817 if (p_ptr->redraw & (PR_CUT))
5819 p_ptr->redraw &= ~(PR_CUT);
5823 if (p_ptr->redraw & (PR_STUN))
5825 p_ptr->redraw &= ~(PR_STUN);
5829 if (p_ptr->redraw & (PR_HUNGER))
5831 p_ptr->redraw &= ~(PR_HUNGER);
5835 if (p_ptr->redraw & (PR_STATE))
5837 p_ptr->redraw &= ~(PR_STATE);
5841 if (p_ptr->redraw & (PR_SPEED))
5843 p_ptr->redraw &= ~(PR_SPEED);
5847 if (p_ptr->pclass == CLASS_IMITATOR)
5849 if (p_ptr->redraw & (PR_MANE))
5851 p_ptr->redraw &= ~(PR_MANE);
5855 else if (p_ptr->redraw & (PR_STUDY))
5857 p_ptr->redraw &= ~(PR_STUDY);
5864 * Handle "p_ptr->window"
5866 void window_stuff(void)
5874 if (!p_ptr->window) return;
5877 for (j = 0; j < 8; j++)
5879 /* Save usable flags */
5880 if (angband_term[j]) mask |= window_flag[j];
5883 /* Apply usable flags */
5884 p_ptr->window &= mask;
5887 if (!p_ptr->window) return;
5890 /* Display inventory */
5891 if (p_ptr->window & (PW_INVEN))
5893 p_ptr->window &= ~(PW_INVEN);
5897 /* Display equipment */
5898 if (p_ptr->window & (PW_EQUIP))
5900 p_ptr->window &= ~(PW_EQUIP);
5904 /* Display spell list */
5905 if (p_ptr->window & (PW_SPELL))
5907 p_ptr->window &= ~(PW_SPELL);
5911 /* Display player */
5912 if (p_ptr->window & (PW_PLAYER))
5914 p_ptr->window &= ~(PW_PLAYER);
5918 /* Display overhead view */
5919 if (p_ptr->window & (PW_MESSAGE))
5921 p_ptr->window &= ~(PW_MESSAGE);
5925 /* Display overhead view */
5926 if (p_ptr->window & (PW_OVERHEAD))
5928 p_ptr->window &= ~(PW_OVERHEAD);
5932 /* Display overhead view */
5933 if (p_ptr->window & (PW_DUNGEON))
5935 p_ptr->window &= ~(PW_DUNGEON);
5939 /* Display monster recall */
5940 if (p_ptr->window & (PW_MONSTER))
5942 p_ptr->window &= ~(PW_MONSTER);
5946 /* Display object recall */
5947 if (p_ptr->window & (PW_OBJECT))
5949 p_ptr->window &= ~(PW_OBJECT);
5956 * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window"
5958 void handle_stuff(void)
5961 if (p_ptr->update) update_stuff();
5964 if (p_ptr->redraw) redraw_stuff();
5967 if (p_ptr->window) window_stuff();
5971 s16b empty_hands(bool is_monk)
5973 s16b status = EMPTY_HAND_NONE;
5974 if (is_monk && (p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_BERSERKER)) return EMPTY_HAND_NONE;
5976 if (!(inventory[INVEN_RARM].k_idx)) status |= EMPTY_HAND_RARM;
5977 if (!(inventory[INVEN_LARM].k_idx)) status |= EMPTY_HAND_LARM;
5982 bool heavy_armor(void)
5984 u16b monk_arm_wgt = 0;
5986 if ((p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_NINJA)) return FALSE;
5988 /* Weight the armor */
5989 if(inventory[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_RARM].weight;
5990 if(inventory[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_LARM].weight;
5991 monk_arm_wgt += inventory[INVEN_BODY].weight;
5992 monk_arm_wgt += inventory[INVEN_HEAD].weight;
5993 monk_arm_wgt += inventory[INVEN_OUTER].weight;
5994 monk_arm_wgt += inventory[INVEN_HANDS].weight;
5995 monk_arm_wgt += inventory[INVEN_FEET].weight;
5997 return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));