3 #include "player-status.h"
7 * Return alignment title
9 concptr your_alignment(void)
11 if (p_ptr->align > 150) return _("大善", "Lawful");
12 else if (p_ptr->align > 50) return _("中善", "Good");
13 else if (p_ptr->align > 10) return _("小善", "Neutral Good");
14 else if (p_ptr->align > -11) return _("中立", "Neutral");
15 else if (p_ptr->align > -51) return _("小悪", "Neutral Evil");
16 else if (p_ptr->align > -151) return _("中悪", "Evil");
17 else return _("大悪", "Chaotic");
22 * Return proficiency level of weapons and misc. skills (except riding)
24 int weapon_exp_level(int weapon_exp)
26 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
27 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
28 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
29 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
30 else return EXP_LEVEL_MASTER;
35 * Return proficiency level of riding
37 int riding_exp_level(int riding_exp)
39 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
40 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
41 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
42 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
43 else return EXP_LEVEL_MASTER;
48 * Return proficiency level of spells
50 int spell_exp_level(int spell_exp)
52 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
53 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
54 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
55 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
56 else return EXP_LEVEL_MASTER;
60 * @brief プレイヤーの全ステータスを更新する /
61 * Calculate the players current "state", taking into account
62 * not only race/class intrinsics, but also objects being worn
63 * and temporary spell effects.
67 * See also calc_mana() and calc_hitpoints().
69 * Take note of the new "speed code", in particular, a very strong
70 * player will start slowing down as soon as he reaches 150 pounds,
71 * but not until he reaches 450 pounds will he be half as fast as
72 * a normal kobold. This both hurts and helps the player, hurts
73 * because in the old days a player could just avoid 300 pounds,
74 * and helps because now carrying 300 pounds is not very painful.
76 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
77 * damage, since that would affect non-combat things. These values
78 * are actually added in later, at the appropriate place.
80 * This function induces various "status" messages.
83 void calc_bonuses(void)
85 int i, j, hold, neutral[2];
88 int empty_hands_status = empty_hands(TRUE);
91 BIT_FLAGS flgs[TR_FLAG_SIZE];
94 bool down_saving = FALSE;
96 bool have_dd_s = FALSE, have_dd_t = FALSE;
98 bool have_sw = FALSE, have_kabe = FALSE;
99 bool easy_2weapon = FALSE;
100 bool riding_levitation = FALSE;
101 OBJECT_IDX this_o_idx, next_o_idx = 0;
102 const player_race *tmp_rp_ptr;
104 /* Save the old vision stuff */
105 bool old_telepathy = p_ptr->telepathy;
106 bool old_esp_animal = p_ptr->esp_animal;
107 bool old_esp_undead = p_ptr->esp_undead;
108 bool old_esp_demon = p_ptr->esp_demon;
109 bool old_esp_orc = p_ptr->esp_orc;
110 bool old_esp_troll = p_ptr->esp_troll;
111 bool old_esp_giant = p_ptr->esp_giant;
112 bool old_esp_dragon = p_ptr->esp_dragon;
113 bool old_esp_human = p_ptr->esp_human;
114 bool old_esp_evil = p_ptr->esp_evil;
115 bool old_esp_good = p_ptr->esp_good;
116 bool old_esp_nonliving = p_ptr->esp_nonliving;
117 bool old_esp_unique = p_ptr->esp_unique;
118 bool old_see_inv = p_ptr->see_inv;
119 bool old_mighty_throw = p_ptr->mighty_throw;
121 /* Current feature under player. */
122 feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
124 /* Save the old armor class */
125 ARMOUR_CLASS old_dis_ac = p_ptr->dis_ac;
126 ARMOUR_CLASS old_dis_to_a = p_ptr->dis_to_a;
129 /* Clear extra blows/shots */
130 extra_blows[0] = extra_blows[1] = 0;
132 /* Clear the stat modifiers */
133 for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] = 0;
136 /* Clear the Displayed/Real armor class */
137 p_ptr->dis_ac = p_ptr->ac = 0;
139 /* Clear the Displayed/Real Bonuses */
140 p_ptr->dis_to_h[0] = p_ptr->to_h[0] = 0;
141 p_ptr->dis_to_h[1] = p_ptr->to_h[1] = 0;
142 p_ptr->dis_to_d[0] = p_ptr->to_d[0] = 0;
143 p_ptr->dis_to_d[1] = p_ptr->to_d[1] = 0;
144 p_ptr->dis_to_h_b = p_ptr->to_h_b = 0;
145 p_ptr->dis_to_a = p_ptr->to_a = 0;
149 p_ptr->to_m_chance = 0;
151 /* Clear the Extra Dice Bonuses */
152 p_ptr->to_dd[0] = p_ptr->to_ds[0] = 0;
153 p_ptr->to_dd[1] = p_ptr->to_ds[1] = 0;
155 /* Start with "normal" speed */
158 /* Start with a single blow per turn */
159 p_ptr->num_blow[0] = 1;
160 p_ptr->num_blow[1] = 1;
162 /* Start with a single shot per turn */
163 p_ptr->num_fire = 100;
165 /* Reset the "xtra" tval */
166 p_ptr->tval_xtra = 0;
168 /* Reset the "ammo" tval */
169 p_ptr->tval_ammo = 0;
171 /* Clear all the flags */
173 p_ptr->bless_blade = FALSE;
174 p_ptr->xtra_might = FALSE;
175 p_ptr->impact[0] = FALSE;
176 p_ptr->impact[1] = FALSE;
177 p_ptr->pass_wall = FALSE;
178 p_ptr->kill_wall = FALSE;
179 p_ptr->dec_mana = FALSE;
180 p_ptr->easy_spell = FALSE;
181 p_ptr->heavy_spell = FALSE;
182 p_ptr->see_inv = FALSE;
183 p_ptr->free_act = FALSE;
184 p_ptr->slow_digest = FALSE;
185 p_ptr->regenerate = FALSE;
186 p_ptr->can_swim = FALSE;
187 p_ptr->levitation = FALSE;
188 p_ptr->hold_exp = FALSE;
189 p_ptr->telepathy = FALSE;
190 p_ptr->esp_animal = FALSE;
191 p_ptr->esp_undead = FALSE;
192 p_ptr->esp_demon = FALSE;
193 p_ptr->esp_orc = FALSE;
194 p_ptr->esp_troll = FALSE;
195 p_ptr->esp_giant = FALSE;
196 p_ptr->esp_dragon = FALSE;
197 p_ptr->esp_human = FALSE;
198 p_ptr->esp_evil = FALSE;
199 p_ptr->esp_good = FALSE;
200 p_ptr->esp_nonliving = FALSE;
201 p_ptr->esp_unique = FALSE;
203 p_ptr->sustain_str = FALSE;
204 p_ptr->sustain_int = FALSE;
205 p_ptr->sustain_wis = FALSE;
206 p_ptr->sustain_con = FALSE;
207 p_ptr->sustain_dex = FALSE;
208 p_ptr->sustain_chr = FALSE;
209 p_ptr->resist_acid = FALSE;
210 p_ptr->resist_elec = FALSE;
211 p_ptr->resist_fire = FALSE;
212 p_ptr->resist_cold = FALSE;
213 p_ptr->resist_pois = FALSE;
214 p_ptr->resist_conf = FALSE;
215 p_ptr->resist_sound = FALSE;
216 p_ptr->resist_lite = FALSE;
217 p_ptr->resist_dark = FALSE;
218 p_ptr->resist_chaos = FALSE;
219 p_ptr->resist_disen = FALSE;
220 p_ptr->resist_shard = FALSE;
221 p_ptr->resist_nexus = FALSE;
222 p_ptr->resist_blind = FALSE;
223 p_ptr->resist_neth = FALSE;
224 p_ptr->resist_time = FALSE;
225 p_ptr->resist_water = FALSE;
226 p_ptr->resist_fear = FALSE;
227 p_ptr->reflect = FALSE;
228 p_ptr->sh_fire = FALSE;
229 p_ptr->sh_elec = FALSE;
230 p_ptr->sh_cold = FALSE;
231 p_ptr->anti_magic = FALSE;
232 p_ptr->anti_tele = FALSE;
233 p_ptr->warning = FALSE;
234 p_ptr->mighty_throw = FALSE;
235 p_ptr->see_nocto = FALSE;
237 p_ptr->immune_acid = FALSE;
238 p_ptr->immune_elec = FALSE;
239 p_ptr->immune_fire = FALSE;
240 p_ptr->immune_cold = FALSE;
242 p_ptr->ryoute = FALSE;
243 p_ptr->migite = FALSE;
244 p_ptr->hidarite = FALSE;
245 p_ptr->no_flowed = FALSE;
247 p_ptr->align = friend_align;
249 if (p_ptr->mimic_form) tmp_rp_ptr = &mimic_info[p_ptr->mimic_form];
250 else tmp_rp_ptr = &race_info[p_ptr->prace];
252 /* Base infravision (purely racial) */
253 p_ptr->see_infra = tmp_rp_ptr->infra;
255 /* Base skill -- disarming */
256 p_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
258 /* Base skill -- magic devices */
259 p_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
261 /* Base skill -- saving throw */
262 p_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
264 /* Base skill -- stealth */
265 p_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
267 /* Base skill -- searching ability */
268 p_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
270 /* Base skill -- searching frequency */
271 p_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
273 /* Base skill -- combat (normal) */
274 p_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
276 /* Base skill -- combat (shooting) */
277 p_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
279 /* Base skill -- combat (throwing) */
280 p_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
282 /* Base skill -- digging */
283 p_ptr->skill_dig = 0;
285 if (buki_motteruka(INVEN_RARM)) p_ptr->migite = TRUE;
286 if (buki_motteruka(INVEN_LARM))
288 p_ptr->hidarite = TRUE;
289 if (!p_ptr->migite) default_hand = 1;
292 if (CAN_TWO_HANDS_WIELDING())
294 if (p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
295 object_allow_two_hands_wielding(&inventory[INVEN_RARM]))
297 p_ptr->ryoute = TRUE;
299 else if (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
300 object_allow_two_hands_wielding(&inventory[INVEN_LARM]))
302 p_ptr->ryoute = TRUE;
306 switch (p_ptr->pclass)
309 case CLASS_FORCETRAINER:
310 case CLASS_BERSERKER:
311 if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
313 p_ptr->migite = TRUE;
314 p_ptr->ryoute = TRUE;
321 if (!p_ptr->migite && !p_ptr->hidarite)
323 if (empty_hands_status & EMPTY_HAND_RARM) p_ptr->migite = TRUE;
324 else if (empty_hands_status == EMPTY_HAND_LARM)
326 p_ptr->hidarite = TRUE;
331 if (p_ptr->special_defense & KAMAE_MASK)
333 if (!(empty_hands_status & EMPTY_HAND_RARM))
335 set_action(ACTION_NONE);
339 switch (p_ptr->pclass)
342 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
343 if (p_ptr->lev > 44) p_ptr->regenerate = TRUE;
346 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
348 case CLASS_CHAOS_WARRIOR:
349 if (p_ptr->lev > 29) p_ptr->resist_chaos = TRUE;
350 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
352 case CLASS_MINDCRAFTER:
353 if (p_ptr->lev > 9) p_ptr->resist_fear = TRUE;
354 if (p_ptr->lev > 19) p_ptr->sustain_wis = TRUE;
355 if (p_ptr->lev > 29) p_ptr->resist_conf = TRUE;
356 if (p_ptr->lev > 39) p_ptr->telepathy = TRUE;
359 case CLASS_FORCETRAINER:
360 /* Unencumbered Monks become faster every 10 levels */
361 if (!(heavy_armor()))
363 if (!(prace_is_(RACE_KLACKON) ||
364 prace_is_(RACE_SPRITE) ||
365 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
366 new_speed += (p_ptr->lev) / 10;
368 /* Free action if unencumbered at level 25 */
370 p_ptr->free_act = TRUE;
375 p_ptr->dis_to_a -= 50;
378 p_ptr->resist_sound = TRUE;
381 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
383 case CLASS_BERSERKER:
385 p_ptr->sustain_str = TRUE;
386 p_ptr->sustain_dex = TRUE;
387 p_ptr->sustain_con = TRUE;
388 p_ptr->regenerate = TRUE;
389 p_ptr->free_act = TRUE;
391 if (p_ptr->lev > 29) new_speed++;
392 if (p_ptr->lev > 39) new_speed++;
393 if (p_ptr->lev > 44) new_speed++;
394 if (p_ptr->lev > 49) new_speed++;
395 p_ptr->to_a += 10 + p_ptr->lev / 2;
396 p_ptr->dis_to_a += 10 + p_ptr->lev / 2;
397 p_ptr->skill_dig += (100 + p_ptr->lev * 8);
398 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
399 p_ptr->redraw |= PR_STATUS;
401 case CLASS_MIRROR_MASTER:
402 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
405 /* Unencumbered Ninjas become faster every 10 levels */
408 new_speed -= (p_ptr->lev) / 10;
409 p_ptr->skill_stl -= (p_ptr->lev) / 10;
411 else if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
412 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
415 if (!(prace_is_(RACE_KLACKON) ||
416 prace_is_(RACE_SPRITE) ||
417 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
418 new_speed += (p_ptr->lev) / 10;
419 p_ptr->skill_stl += (p_ptr->lev) / 10;
421 /* Free action if unencumbered at level 25 */
423 p_ptr->free_act = TRUE;
425 if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
426 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
428 p_ptr->to_a += p_ptr->lev / 2 + 5;
429 p_ptr->dis_to_a += p_ptr->lev / 2 + 5;
431 p_ptr->slow_digest = TRUE;
432 p_ptr->resist_fear = TRUE;
433 if (p_ptr->lev > 19) p_ptr->resist_pois = TRUE;
434 if (p_ptr->lev > 24) p_ptr->sustain_dex = TRUE;
435 if (p_ptr->lev > 29) p_ptr->see_inv = TRUE;
438 p_ptr->oppose_pois = 1;
439 p_ptr->redraw |= PR_STATUS;
441 p_ptr->see_nocto = TRUE;
446 if (p_ptr->mimic_form)
448 switch (p_ptr->mimic_form)
451 p_ptr->hold_exp = TRUE;
452 p_ptr->resist_chaos = TRUE;
453 p_ptr->resist_neth = TRUE;
454 p_ptr->resist_fire = TRUE;
455 p_ptr->oppose_fire = 1;
456 p_ptr->see_inv = TRUE;
458 p_ptr->redraw |= PR_STATUS;
460 p_ptr->dis_to_a += 10;
463 case MIMIC_DEMON_LORD:
464 p_ptr->hold_exp = TRUE;
465 p_ptr->resist_chaos = TRUE;
466 p_ptr->resist_neth = TRUE;
467 p_ptr->immune_fire = TRUE;
468 p_ptr->resist_acid = TRUE;
469 p_ptr->resist_fire = TRUE;
470 p_ptr->resist_cold = TRUE;
471 p_ptr->resist_elec = TRUE;
472 p_ptr->resist_pois = TRUE;
473 p_ptr->resist_conf = TRUE;
474 p_ptr->resist_disen = TRUE;
475 p_ptr->resist_nexus = TRUE;
476 p_ptr->resist_fear = TRUE;
477 p_ptr->sh_fire = TRUE;
478 p_ptr->see_inv = TRUE;
479 p_ptr->telepathy = TRUE;
480 p_ptr->levitation = TRUE;
481 p_ptr->kill_wall = TRUE;
484 p_ptr->dis_to_a += 20;
488 p_ptr->resist_dark = TRUE;
489 p_ptr->hold_exp = TRUE;
490 p_ptr->resist_neth = TRUE;
491 p_ptr->resist_cold = TRUE;
492 p_ptr->resist_pois = TRUE;
493 p_ptr->see_inv = TRUE;
496 p_ptr->dis_to_a += 10;
497 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
503 switch (p_ptr->prace)
506 p_ptr->resist_lite = TRUE;
509 p_ptr->hold_exp = TRUE;
512 p_ptr->free_act = TRUE;
515 p_ptr->resist_blind = TRUE;
518 p_ptr->resist_dark = TRUE;
520 case RACE_HALF_TROLL:
521 p_ptr->sustain_str = TRUE;
525 /* High level trolls heal fast... */
526 p_ptr->regenerate = TRUE;
528 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_BERSERKER)
530 p_ptr->slow_digest = TRUE;
531 /* Let's not make Regeneration
532 * a disadvantage for the poor warriors who can
533 * never learn a spell that satisfies hunger (actually
534 * neither can rogues, but half-trolls are not
535 * supposed to play rogues) */
540 p_ptr->sustain_con = TRUE;
541 p_ptr->regenerate = TRUE; /* Amberites heal fast... */
544 p_ptr->resist_lite = TRUE;
545 p_ptr->see_inv = TRUE;
548 p_ptr->resist_fear = TRUE;
551 p_ptr->resist_dark = TRUE;
552 p_ptr->sustain_str = TRUE;
554 case RACE_HALF_GIANT:
555 p_ptr->sustain_str = TRUE;
556 p_ptr->resist_shard = TRUE;
558 case RACE_HALF_TITAN:
559 p_ptr->resist_chaos = TRUE;
562 p_ptr->resist_sound = TRUE;
565 p_ptr->resist_acid = TRUE;
566 if (p_ptr->lev > 19) p_ptr->immune_acid = TRUE;
569 p_ptr->resist_conf = TRUE;
570 p_ptr->resist_acid = TRUE;
572 /* Klackons become faster */
573 new_speed += (p_ptr->lev) / 10;
576 p_ptr->resist_pois = TRUE;
579 p_ptr->resist_disen = TRUE;
580 p_ptr->resist_dark = TRUE;
583 p_ptr->resist_dark = TRUE;
584 if (p_ptr->lev > 19) p_ptr->see_inv = TRUE;
587 p_ptr->levitation = TRUE;
588 if (p_ptr->lev > 4) p_ptr->resist_fire = TRUE;
589 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
590 if (p_ptr->lev > 14) p_ptr->resist_acid = TRUE;
591 if (p_ptr->lev > 19) p_ptr->resist_elec = TRUE;
592 if (p_ptr->lev > 34) p_ptr->resist_pois = TRUE;
594 case RACE_MIND_FLAYER:
595 p_ptr->sustain_int = TRUE;
596 p_ptr->sustain_wis = TRUE;
597 if (p_ptr->lev > 14) p_ptr->see_inv = TRUE;
598 if (p_ptr->lev > 29) p_ptr->telepathy = TRUE;
601 p_ptr->resist_fire = TRUE;
602 if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
605 p_ptr->slow_digest = TRUE;
606 p_ptr->free_act = TRUE;
607 p_ptr->see_inv = TRUE;
608 p_ptr->resist_pois = TRUE;
609 if (p_ptr->lev > 34) p_ptr->hold_exp = TRUE;
612 p_ptr->resist_shard = TRUE;
613 p_ptr->hold_exp = TRUE;
614 p_ptr->see_inv = TRUE;
615 p_ptr->resist_pois = TRUE;
616 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
619 p_ptr->resist_neth = TRUE;
620 p_ptr->hold_exp = TRUE;
621 p_ptr->see_inv = TRUE;
622 p_ptr->resist_pois = TRUE;
623 p_ptr->slow_digest = TRUE;
624 if (p_ptr->lev > 4) p_ptr->resist_cold = TRUE;
627 p_ptr->resist_dark = TRUE;
628 p_ptr->hold_exp = TRUE;
629 p_ptr->resist_neth = TRUE;
630 p_ptr->resist_cold = TRUE;
631 p_ptr->resist_pois = TRUE;
632 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
635 p_ptr->levitation = TRUE;
636 p_ptr->free_act = TRUE;
637 p_ptr->resist_neth = TRUE;
638 p_ptr->hold_exp = TRUE;
639 p_ptr->see_inv = TRUE;
640 p_ptr->resist_pois = TRUE;
641 p_ptr->slow_digest = TRUE;
642 p_ptr->resist_cold = TRUE;
643 p_ptr->pass_wall = TRUE;
644 if (p_ptr->lev > 34) p_ptr->telepathy = TRUE;
647 p_ptr->levitation = TRUE;
648 p_ptr->resist_lite = TRUE;
650 /* Sprites become faster */
651 new_speed += (p_ptr->lev) / 10;
654 p_ptr->resist_conf = TRUE;
655 p_ptr->resist_sound = TRUE;
658 /* Ents dig like maniacs, but only with their hands. */
659 if (!inventory[INVEN_RARM].k_idx)
660 p_ptr->skill_dig += p_ptr->lev * 10;
661 /* Ents get tougher and stronger as they age, but lose dexterity. */
662 if (p_ptr->lev > 25) p_ptr->stat_add[A_STR]++;
663 if (p_ptr->lev > 40) p_ptr->stat_add[A_STR]++;
664 if (p_ptr->lev > 45) p_ptr->stat_add[A_STR]++;
666 if (p_ptr->lev > 25) p_ptr->stat_add[A_DEX]--;
667 if (p_ptr->lev > 40) p_ptr->stat_add[A_DEX]--;
668 if (p_ptr->lev > 45) p_ptr->stat_add[A_DEX]--;
670 if (p_ptr->lev > 25) p_ptr->stat_add[A_CON]++;
671 if (p_ptr->lev > 40) p_ptr->stat_add[A_CON]++;
672 if (p_ptr->lev > 45) p_ptr->stat_add[A_CON]++;
675 p_ptr->levitation = TRUE;
676 p_ptr->see_inv = TRUE;
680 p_ptr->resist_fire = TRUE;
681 p_ptr->resist_neth = TRUE;
682 p_ptr->hold_exp = TRUE;
683 if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
686 p_ptr->oppose_fire = 1;
687 p_ptr->redraw |= PR_STATUS;
692 p_ptr->sustain_con = TRUE;
695 p_ptr->levitation = TRUE;
698 p_ptr->resist_conf = TRUE;
701 p_ptr->slow_digest = TRUE;
702 p_ptr->free_act = TRUE;
703 p_ptr->resist_pois = TRUE;
704 p_ptr->hold_exp = TRUE;
707 p_ptr->resist_water = TRUE;
715 if (p_ptr->ult_res || (p_ptr->special_defense & KATA_MUSOU))
717 p_ptr->see_inv = TRUE;
718 p_ptr->free_act = TRUE;
719 p_ptr->slow_digest = TRUE;
720 p_ptr->regenerate = TRUE;
721 p_ptr->levitation = TRUE;
722 p_ptr->hold_exp = TRUE;
723 p_ptr->telepathy = TRUE;
725 p_ptr->sustain_str = TRUE;
726 p_ptr->sustain_int = TRUE;
727 p_ptr->sustain_wis = TRUE;
728 p_ptr->sustain_con = TRUE;
729 p_ptr->sustain_dex = TRUE;
730 p_ptr->sustain_chr = TRUE;
731 p_ptr->resist_acid = TRUE;
732 p_ptr->resist_elec = TRUE;
733 p_ptr->resist_fire = TRUE;
734 p_ptr->resist_cold = TRUE;
735 p_ptr->resist_pois = TRUE;
736 p_ptr->resist_conf = TRUE;
737 p_ptr->resist_sound = TRUE;
738 p_ptr->resist_lite = TRUE;
739 p_ptr->resist_dark = TRUE;
740 p_ptr->resist_chaos = TRUE;
741 p_ptr->resist_disen = TRUE;
742 p_ptr->resist_shard = TRUE;
743 p_ptr->resist_nexus = TRUE;
744 p_ptr->resist_blind = TRUE;
745 p_ptr->resist_neth = TRUE;
746 p_ptr->resist_fear = TRUE;
747 p_ptr->reflect = TRUE;
748 p_ptr->sh_fire = TRUE;
749 p_ptr->sh_elec = TRUE;
750 p_ptr->sh_cold = TRUE;
752 p_ptr->dis_to_a += 100;
754 /* Temporary shield */
755 else if (p_ptr->tsubureru || p_ptr->shield || p_ptr->magicdef)
758 p_ptr->dis_to_a += 50;
761 if (p_ptr->tim_res_nether)
763 p_ptr->resist_neth = TRUE;
765 if (p_ptr->tim_sh_fire)
767 p_ptr->sh_fire = TRUE;
769 if (p_ptr->tim_res_time)
771 p_ptr->resist_time = TRUE;
775 if (p_ptr->pseikaku == SEIKAKU_SEXY) p_ptr->cursed |= (TRC_AGGRAVATE);
777 if (p_ptr->pseikaku == SEIKAKU_NAMAKE) p_ptr->to_m_chance += 10;
778 if (p_ptr->pseikaku == SEIKAKU_KIREMONO) p_ptr->to_m_chance -= 3;
779 if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) p_ptr->to_m_chance++;
781 if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
783 p_ptr->to_m_chance += 5;
784 p_ptr->resist_conf = TRUE;
788 if (p_ptr->pseikaku == SEIKAKU_LUCKY) p_ptr->muta3 |= MUT3_GOOD_LUCK;
790 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
792 p_ptr->resist_blind = TRUE;
793 p_ptr->resist_conf = TRUE;
794 p_ptr->hold_exp = TRUE;
795 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
797 if ((p_ptr->prace != RACE_KLACKON) && (p_ptr->prace != RACE_SPRITE))
798 /* Munchkin become faster */
799 new_speed += (p_ptr->lev) / 10 + 5;
802 if (music_singing(MUSIC_WALL))
804 p_ptr->kill_wall = TRUE;
807 /* Hack -- apply racial/class stat maxes */
808 /* Apply the racial modifiers */
809 for (i = 0; i < A_MAX; i++)
811 /* Modify the stats for "race" */
812 p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
816 /* I'm adding the mutations here for the lack of a better place... */
820 if (p_ptr->muta3 & MUT3_HYPER_STR)
822 p_ptr->stat_add[A_STR] += 4;
826 if (p_ptr->muta3 & MUT3_PUNY)
828 p_ptr->stat_add[A_STR] -= 4;
831 /* Living computer */
832 if (p_ptr->muta3 & MUT3_HYPER_INT)
834 p_ptr->stat_add[A_INT] += 4;
835 p_ptr->stat_add[A_WIS] += 4;
839 if (p_ptr->muta3 & MUT3_MORONIC)
841 p_ptr->stat_add[A_INT] -= 4;
842 p_ptr->stat_add[A_WIS] -= 4;
845 if (p_ptr->muta3 & MUT3_RESILIENT)
847 p_ptr->stat_add[A_CON] += 4;
850 if (p_ptr->muta3 & MUT3_XTRA_FAT)
852 p_ptr->stat_add[A_CON] += 2;
856 if (p_ptr->muta3 & MUT3_ALBINO)
858 p_ptr->stat_add[A_CON] -= 4;
861 if (p_ptr->muta3 & MUT3_FLESH_ROT)
863 p_ptr->stat_add[A_CON] -= 2;
864 p_ptr->stat_add[A_CHR] -= 1;
865 p_ptr->regenerate = FALSE;
866 /* Cancel innate regeneration */
869 if (p_ptr->muta3 & MUT3_SILLY_VOI)
871 p_ptr->stat_add[A_CHR] -= 4;
874 if (p_ptr->muta3 & MUT3_BLANK_FAC)
876 p_ptr->stat_add[A_CHR] -= 1;
879 if (p_ptr->muta3 & MUT3_XTRA_EYES)
881 p_ptr->skill_fos += 15;
882 p_ptr->skill_srh += 15;
885 if (p_ptr->muta3 & MUT3_MAGIC_RES)
887 p_ptr->skill_sav += (15 + (p_ptr->lev / 5));
890 if (p_ptr->muta3 & MUT3_XTRA_NOIS)
892 p_ptr->skill_stl -= 3;
895 if (p_ptr->muta3 & MUT3_INFRAVIS)
897 p_ptr->see_infra += 3;
900 if (p_ptr->muta3 & MUT3_XTRA_LEGS)
905 if (p_ptr->muta3 & MUT3_SHORT_LEG)
910 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
912 p_ptr->sh_elec = TRUE;
915 if (p_ptr->muta3 & MUT3_FIRE_BODY)
917 p_ptr->sh_fire = TRUE;
921 if (p_ptr->muta3 & MUT3_WART_SKIN)
923 p_ptr->stat_add[A_CHR] -= 2;
925 p_ptr->dis_to_a += 5;
928 if (p_ptr->muta3 & MUT3_SCALES)
930 p_ptr->stat_add[A_CHR] -= 1;
932 p_ptr->dis_to_a += 10;
935 if (p_ptr->muta3 & MUT3_IRON_SKIN)
937 p_ptr->stat_add[A_DEX] -= 1;
939 p_ptr->dis_to_a += 25;
942 if (p_ptr->muta3 & MUT3_WINGS)
944 p_ptr->levitation = TRUE;
947 if (p_ptr->muta3 & MUT3_FEARLESS)
949 p_ptr->resist_fear = TRUE;
952 if (p_ptr->muta3 & MUT3_REGEN)
954 p_ptr->regenerate = TRUE;
957 if (p_ptr->muta3 & MUT3_ESP)
959 p_ptr->telepathy = TRUE;
962 if (p_ptr->muta3 & MUT3_LIMBER)
964 p_ptr->stat_add[A_DEX] += 3;
967 if (p_ptr->muta3 & MUT3_ARTHRITIS)
969 p_ptr->stat_add[A_DEX] -= 3;
972 if (p_ptr->muta3 & MUT3_MOTION)
974 p_ptr->free_act = TRUE;
975 p_ptr->skill_stl += 1;
978 if (p_ptr->muta3 & MUT3_ILL_NORM)
980 p_ptr->stat_add[A_CHR] = 0;
986 p_ptr->stat_add[A_STR] += 4;
987 p_ptr->stat_add[A_CON] += 4;
990 /* Scan the usable inventory */
991 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
993 int bonus_to_h, bonus_to_d;
994 o_ptr = &inventory[i];
996 /* Skip non-objects */
997 if (!o_ptr->k_idx) continue;
999 /* Extract the item flags */
1000 object_flags(o_ptr, flgs);
1002 p_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
1003 if (o_ptr->name1 == ART_CHAINSWORD) p_ptr->cursed |= TRC_CHAINSWORD;
1006 if (have_flag(flgs, TR_STR)) p_ptr->stat_add[A_STR] += o_ptr->pval;
1007 if (have_flag(flgs, TR_INT)) p_ptr->stat_add[A_INT] += o_ptr->pval;
1008 if (have_flag(flgs, TR_WIS)) p_ptr->stat_add[A_WIS] += o_ptr->pval;
1009 if (have_flag(flgs, TR_DEX)) p_ptr->stat_add[A_DEX] += o_ptr->pval;
1010 if (have_flag(flgs, TR_CON)) p_ptr->stat_add[A_CON] += o_ptr->pval;
1011 if (have_flag(flgs, TR_CHR)) p_ptr->stat_add[A_CHR] += o_ptr->pval;
1013 if (have_flag(flgs, TR_MAGIC_MASTERY)) p_ptr->skill_dev += 8 * o_ptr->pval;
1015 /* Affect stealth */
1016 if (have_flag(flgs, TR_STEALTH)) p_ptr->skill_stl += o_ptr->pval;
1018 /* Affect searching ability (factor of five) */
1019 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_srh += (o_ptr->pval * 5);
1021 /* Affect searching frequency (factor of five) */
1022 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_fos += (o_ptr->pval * 5);
1024 /* Affect infravision */
1025 if (have_flag(flgs, TR_INFRA)) p_ptr->see_infra += o_ptr->pval;
1027 /* Affect digging (factor of 20) */
1028 if (have_flag(flgs, TR_TUNNEL)) p_ptr->skill_dig += (o_ptr->pval * 20);
1031 if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
1034 if (have_flag(flgs, TR_BLOWS))
1036 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !p_ptr->ryoute) extra_blows[0] += o_ptr->pval;
1037 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !p_ptr->ryoute) extra_blows[1] += o_ptr->pval;
1038 else { extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval; }
1041 /* Hack -- cause earthquakes */
1042 if (have_flag(flgs, TR_IMPACT)) p_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
1045 if (have_flag(flgs, TR_AGGRAVATE)) p_ptr->cursed |= TRC_AGGRAVATE;
1046 if (have_flag(flgs, TR_DRAIN_EXP)) p_ptr->cursed |= TRC_DRAIN_EXP;
1047 if (have_flag(flgs, TR_TY_CURSE)) p_ptr->cursed |= TRC_TY_CURSE;
1048 if (have_flag(flgs, TR_ADD_L_CURSE)) p_ptr->cursed |= TRC_ADD_L_CURSE;
1049 if (have_flag(flgs, TR_ADD_H_CURSE)) p_ptr->cursed |= TRC_ADD_H_CURSE;
1050 if (have_flag(flgs, TR_DRAIN_HP)) p_ptr->cursed |= TRC_DRAIN_HP;
1051 if (have_flag(flgs, TR_DRAIN_MANA)) p_ptr->cursed |= TRC_DRAIN_MANA;
1052 if (have_flag(flgs, TR_CALL_ANIMAL)) p_ptr->cursed |= TRC_CALL_ANIMAL;
1053 if (have_flag(flgs, TR_CALL_DEMON)) p_ptr->cursed |= TRC_CALL_DEMON;
1054 if (have_flag(flgs, TR_CALL_DRAGON)) p_ptr->cursed |= TRC_CALL_DRAGON;
1055 if (have_flag(flgs, TR_CALL_UNDEAD)) p_ptr->cursed |= TRC_CALL_UNDEAD;
1056 if (have_flag(flgs, TR_COWARDICE)) p_ptr->cursed |= TRC_COWARDICE;
1057 if (have_flag(flgs, TR_LOW_MELEE)) p_ptr->cursed |= TRC_LOW_MELEE;
1058 if (have_flag(flgs, TR_LOW_AC)) p_ptr->cursed |= TRC_LOW_AC;
1059 if (have_flag(flgs, TR_LOW_MAGIC)) p_ptr->cursed |= TRC_LOW_MAGIC;
1060 if (have_flag(flgs, TR_FAST_DIGEST)) p_ptr->cursed |= TRC_FAST_DIGEST;
1061 if (have_flag(flgs, TR_SLOW_REGEN)) p_ptr->cursed |= TRC_SLOW_REGEN;
1062 if (have_flag(flgs, TR_DEC_MANA)) p_ptr->dec_mana = TRUE;
1063 if (have_flag(flgs, TR_BLESSED)) p_ptr->bless_blade = TRUE;
1064 if (have_flag(flgs, TR_XTRA_MIGHT)) p_ptr->xtra_might = TRUE;
1065 if (have_flag(flgs, TR_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
1066 if (have_flag(flgs, TR_REGEN)) p_ptr->regenerate = TRUE;
1067 if (have_flag(flgs, TR_TELEPATHY)) p_ptr->telepathy = TRUE;
1068 if (have_flag(flgs, TR_ESP_ANIMAL)) p_ptr->esp_animal = TRUE;
1069 if (have_flag(flgs, TR_ESP_UNDEAD)) p_ptr->esp_undead = TRUE;
1070 if (have_flag(flgs, TR_ESP_DEMON)) p_ptr->esp_demon = TRUE;
1071 if (have_flag(flgs, TR_ESP_ORC)) p_ptr->esp_orc = TRUE;
1072 if (have_flag(flgs, TR_ESP_TROLL)) p_ptr->esp_troll = TRUE;
1073 if (have_flag(flgs, TR_ESP_GIANT)) p_ptr->esp_giant = TRUE;
1074 if (have_flag(flgs, TR_ESP_DRAGON)) p_ptr->esp_dragon = TRUE;
1075 if (have_flag(flgs, TR_ESP_HUMAN)) p_ptr->esp_human = TRUE;
1076 if (have_flag(flgs, TR_ESP_EVIL)) p_ptr->esp_evil = TRUE;
1077 if (have_flag(flgs, TR_ESP_GOOD)) p_ptr->esp_good = TRUE;
1078 if (have_flag(flgs, TR_ESP_NONLIVING)) p_ptr->esp_nonliving = TRUE;
1079 if (have_flag(flgs, TR_ESP_UNIQUE)) p_ptr->esp_unique = TRUE;
1081 if (have_flag(flgs, TR_SEE_INVIS)) p_ptr->see_inv = TRUE;
1082 if (have_flag(flgs, TR_LEVITATION)) p_ptr->levitation = TRUE;
1083 if (have_flag(flgs, TR_FREE_ACT)) p_ptr->free_act = TRUE;
1084 if (have_flag(flgs, TR_HOLD_EXP)) p_ptr->hold_exp = TRUE;
1085 if (have_flag(flgs, TR_WARNING)) {
1086 if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription), '$')))
1087 p_ptr->warning = TRUE;
1090 if (have_flag(flgs, TR_TELEPORT))
1092 if (object_is_cursed(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
1095 concptr insc = quark_str(o_ptr->inscription);
1097 if (o_ptr->inscription && my_strchr(insc, '.'))
1100 * {.} will stop random teleportation.
1105 /* Controlled random teleportation */
1106 p_ptr->cursed |= TRC_TELEPORT_SELF;
1111 /* Immunity flags */
1112 if (have_flag(flgs, TR_IM_FIRE)) p_ptr->immune_fire = TRUE;
1113 if (have_flag(flgs, TR_IM_ACID)) p_ptr->immune_acid = TRUE;
1114 if (have_flag(flgs, TR_IM_COLD)) p_ptr->immune_cold = TRUE;
1115 if (have_flag(flgs, TR_IM_ELEC)) p_ptr->immune_elec = TRUE;
1117 /* Resistance flags */
1118 if (have_flag(flgs, TR_RES_ACID)) p_ptr->resist_acid = TRUE;
1119 if (have_flag(flgs, TR_RES_ELEC)) p_ptr->resist_elec = TRUE;
1120 if (have_flag(flgs, TR_RES_FIRE)) p_ptr->resist_fire = TRUE;
1121 if (have_flag(flgs, TR_RES_COLD)) p_ptr->resist_cold = TRUE;
1122 if (have_flag(flgs, TR_RES_POIS)) p_ptr->resist_pois = TRUE;
1123 if (have_flag(flgs, TR_RES_FEAR)) p_ptr->resist_fear = TRUE;
1124 if (have_flag(flgs, TR_RES_CONF)) p_ptr->resist_conf = TRUE;
1125 if (have_flag(flgs, TR_RES_SOUND)) p_ptr->resist_sound = TRUE;
1126 if (have_flag(flgs, TR_RES_LITE)) p_ptr->resist_lite = TRUE;
1127 if (have_flag(flgs, TR_RES_DARK)) p_ptr->resist_dark = TRUE;
1128 if (have_flag(flgs, TR_RES_CHAOS)) p_ptr->resist_chaos = TRUE;
1129 if (have_flag(flgs, TR_RES_DISEN)) p_ptr->resist_disen = TRUE;
1130 if (have_flag(flgs, TR_RES_SHARDS)) p_ptr->resist_shard = TRUE;
1131 if (have_flag(flgs, TR_RES_NEXUS)) p_ptr->resist_nexus = TRUE;
1132 if (have_flag(flgs, TR_RES_BLIND)) p_ptr->resist_blind = TRUE;
1133 if (have_flag(flgs, TR_RES_NETHER)) p_ptr->resist_neth = TRUE;
1135 if (have_flag(flgs, TR_REFLECT)) p_ptr->reflect = TRUE;
1136 if (have_flag(flgs, TR_SH_FIRE)) p_ptr->sh_fire = TRUE;
1137 if (have_flag(flgs, TR_SH_ELEC)) p_ptr->sh_elec = TRUE;
1138 if (have_flag(flgs, TR_SH_COLD)) p_ptr->sh_cold = TRUE;
1139 if (have_flag(flgs, TR_NO_MAGIC)) p_ptr->anti_magic = TRUE;
1140 if (have_flag(flgs, TR_NO_TELE)) p_ptr->anti_tele = TRUE;
1143 if (have_flag(flgs, TR_SUST_STR)) p_ptr->sustain_str = TRUE;
1144 if (have_flag(flgs, TR_SUST_INT)) p_ptr->sustain_int = TRUE;
1145 if (have_flag(flgs, TR_SUST_WIS)) p_ptr->sustain_wis = TRUE;
1146 if (have_flag(flgs, TR_SUST_DEX)) p_ptr->sustain_dex = TRUE;
1147 if (have_flag(flgs, TR_SUST_CON)) p_ptr->sustain_con = TRUE;
1148 if (have_flag(flgs, TR_SUST_CHR)) p_ptr->sustain_chr = TRUE;
1150 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
1151 if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
1152 if (o_ptr->name2 == EGO_RING_RES_TIME) p_ptr->resist_time = TRUE;
1153 if (o_ptr->name2 == EGO_RING_THROW) p_ptr->mighty_throw = TRUE;
1154 if (have_flag(flgs, TR_EASY_SPELL)) p_ptr->easy_spell = TRUE;
1155 if (o_ptr->name2 == EGO_AMU_FOOL) p_ptr->heavy_spell = TRUE;
1156 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
1158 if (o_ptr->curse_flags & TRC_LOW_MAGIC)
1160 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1162 p_ptr->to_m_chance += 10;
1166 p_ptr->to_m_chance += 3;
1170 if (o_ptr->tval == TV_CAPTURE) continue;
1172 /* Modify the base armor class */
1173 p_ptr->ac += o_ptr->ac;
1175 /* The base armor class is always known */
1176 p_ptr->dis_ac += o_ptr->ac;
1178 /* Apply the bonuses to armor class */
1179 p_ptr->to_a += o_ptr->to_a;
1181 /* Apply the mental bonuses to armor class, if known */
1182 if (object_is_known(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
1184 if (o_ptr->curse_flags & TRC_LOW_MELEE)
1186 int slot = i - INVEN_RARM;
1189 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1191 p_ptr->to_h[slot] -= 15;
1192 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 15;
1196 p_ptr->to_h[slot] -= 5;
1197 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 5;
1202 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1204 p_ptr->to_h_b -= 15;
1205 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 15;
1210 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 5;
1215 if (o_ptr->curse_flags & TRC_LOW_AC)
1217 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1220 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 30;
1225 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 10;
1229 /* Hack -- do not apply "weapon" bonuses */
1230 if (i == INVEN_RARM && buki_motteruka(i)) continue;
1231 if (i == INVEN_LARM && buki_motteruka(i)) continue;
1233 /* Hack -- do not apply "bow" bonuses */
1234 if (i == INVEN_BOW) continue;
1236 bonus_to_h = o_ptr->to_h;
1237 bonus_to_d = o_ptr->to_d;
1239 if (p_ptr->pclass == CLASS_NINJA)
1241 if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h + 1) / 2;
1242 if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d + 1) / 2;
1245 /* To Bow and Natural attack */
1247 /* Apply the bonuses to hit/damage */
1248 p_ptr->to_h_b += (s16b)bonus_to_h;
1249 p_ptr->to_h_m += (s16b)bonus_to_h;
1250 p_ptr->to_d_m += (s16b)bonus_to_d;
1252 /* Apply the mental bonuses tp hit/damage, if known */
1253 if (object_is_known(o_ptr)) p_ptr->dis_to_h_b += (s16b)bonus_to_h;
1256 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
1258 /* Apply the bonuses to hit/damage */
1259 p_ptr->to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
1260 p_ptr->to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
1262 /* Apply the mental bonuses tp hit/damage, if known */
1263 if (object_is_known(o_ptr))
1265 p_ptr->dis_to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
1266 p_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
1269 else if (p_ptr->migite && p_ptr->hidarite)
1271 /* Apply the bonuses to hit/damage */
1272 p_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
1273 p_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
1274 p_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
1275 p_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
1277 /* Apply the mental bonuses tp hit/damage, if known */
1278 if (object_is_known(o_ptr))
1280 p_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
1281 p_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
1282 p_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
1283 p_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
1288 /* Apply the bonuses to hit/damage */
1289 p_ptr->to_h[default_hand] += (s16b)bonus_to_h;
1290 p_ptr->to_d[default_hand] += (s16b)bonus_to_d;
1292 /* Apply the mental bonuses to hit/damage, if known */
1293 if (object_is_known(o_ptr))
1295 p_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
1296 p_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
1301 /* Shield skill bonus */
1302 if (object_is_armour(&inventory[INVEN_RARM]) || object_is_armour(&inventory[INVEN_LARM]))
1304 p_ptr->ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
1305 p_ptr->dis_ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
1308 if (old_mighty_throw != p_ptr->mighty_throw)
1310 /* Redraw average damege display of Shuriken */
1311 p_ptr->window |= PW_INVEN;
1314 if (p_ptr->cursed & TRC_TELEPORT) p_ptr->cursed &= ~(TRC_TELEPORT_SELF);
1316 /* Monks get extra ac for armour _not worn_ */
1317 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor())
1319 if (!(inventory[INVEN_BODY].k_idx))
1321 p_ptr->to_a += (p_ptr->lev * 3) / 2;
1322 p_ptr->dis_to_a += (p_ptr->lev * 3) / 2;
1324 if (!(inventory[INVEN_OUTER].k_idx) && (p_ptr->lev > 15))
1326 p_ptr->to_a += ((p_ptr->lev - 13) / 3);
1327 p_ptr->dis_to_a += ((p_ptr->lev - 13) / 3);
1329 if (!(inventory[INVEN_LARM].k_idx) && (p_ptr->lev > 10))
1331 p_ptr->to_a += ((p_ptr->lev - 8) / 3);
1332 p_ptr->dis_to_a += ((p_ptr->lev - 8) / 3);
1334 if (!(inventory[INVEN_HEAD].k_idx) && (p_ptr->lev > 4))
1336 p_ptr->to_a += (p_ptr->lev - 2) / 3;
1337 p_ptr->dis_to_a += (p_ptr->lev - 2) / 3;
1339 if (!(inventory[INVEN_HANDS].k_idx))
1341 p_ptr->to_a += (p_ptr->lev / 2);
1342 p_ptr->dis_to_a += (p_ptr->lev / 2);
1344 if (!(inventory[INVEN_FEET].k_idx))
1346 p_ptr->to_a += (p_ptr->lev / 3);
1347 p_ptr->dis_to_a += (p_ptr->lev / 3);
1349 if (p_ptr->special_defense & KAMAE_BYAKKO)
1351 p_ptr->stat_add[A_STR] += 2;
1352 p_ptr->stat_add[A_DEX] += 2;
1353 p_ptr->stat_add[A_CON] -= 3;
1355 else if (p_ptr->special_defense & KAMAE_SEIRYU)
1358 else if (p_ptr->special_defense & KAMAE_GENBU)
1360 p_ptr->stat_add[A_INT] -= 1;
1361 p_ptr->stat_add[A_WIS] -= 1;
1362 p_ptr->stat_add[A_DEX] -= 2;
1363 p_ptr->stat_add[A_CON] += 3;
1365 else if (p_ptr->special_defense & KAMAE_SUZAKU)
1367 p_ptr->stat_add[A_STR] -= 2;
1368 p_ptr->stat_add[A_INT] += 1;
1369 p_ptr->stat_add[A_WIS] += 1;
1370 p_ptr->stat_add[A_DEX] += 2;
1371 p_ptr->stat_add[A_CON] -= 2;
1375 if (p_ptr->special_defense & KATA_KOUKIJIN)
1377 for (i = 0; i < A_MAX; i++)
1378 p_ptr->stat_add[i] += 5;
1380 p_ptr->dis_to_a -= 50;
1383 /* Hack -- aura of fire also provides light */
1384 if (p_ptr->sh_fire) p_ptr->lite = TRUE;
1386 /* Golems also get an intrinsic AC bonus */
1387 if (prace_is_(RACE_GOLEM) || prace_is_(RACE_ANDROID))
1389 p_ptr->to_a += 10 + (p_ptr->lev * 2 / 5);
1390 p_ptr->dis_to_a += 10 + (p_ptr->lev * 2 / 5);
1394 if (p_ptr->realm1 == REALM_HEX)
1396 if (hex_spelling_any()) p_ptr->skill_stl -= (1 + CASTING_HEX_NUM(p_ptr));
1397 if (hex_spelling(HEX_DETECT_EVIL)) p_ptr->esp_evil = TRUE;
1398 if (hex_spelling(HEX_XTRA_MIGHT)) p_ptr->stat_add[A_STR] += 4;
1399 if (hex_spelling(HEX_BUILDING))
1401 p_ptr->stat_add[A_STR] += 4;
1402 p_ptr->stat_add[A_DEX] += 4;
1403 p_ptr->stat_add[A_CON] += 4;
1405 if (hex_spelling(HEX_DEMON_AURA))
1407 p_ptr->sh_fire = TRUE;
1408 p_ptr->regenerate = TRUE;
1410 if (hex_spelling(HEX_ICE_ARMOR))
1412 p_ptr->sh_cold = TRUE;
1414 p_ptr->dis_to_a += 30;
1416 if (hex_spelling(HEX_SHOCK_CLOAK))
1418 p_ptr->sh_elec = TRUE;
1421 for (i = INVEN_RARM; i <= INVEN_FEET; i++)
1423 ARMOUR_CLASS ac = 0;
1424 o_ptr = &inventory[i];
1425 if (!o_ptr->k_idx) continue;
1426 if (!object_is_armour(o_ptr)) continue;
1427 if (!object_is_cursed(o_ptr)) continue;
1429 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
1430 if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
1431 p_ptr->to_a += (s16b)ac;
1432 p_ptr->dis_to_a += (s16b)ac;
1436 /* Calculate stats */
1437 for (i = 0; i < A_MAX; i++)
1441 /* Extract the new "stat_use" value for the stat */
1442 top = modify_stat_value(p_ptr->stat_max[i], p_ptr->stat_add[i]);
1444 /* Notice changes */
1445 if (p_ptr->stat_top[i] != top)
1447 /* Save the new value */
1448 p_ptr->stat_top[i] = (s16b)top;
1450 /* Redisplay the stats later */
1451 p_ptr->redraw |= (PR_STATS);
1453 p_ptr->window |= (PW_PLAYER);
1457 /* Extract the new "stat_use" value for the stat */
1458 use = modify_stat_value(p_ptr->stat_cur[i], p_ptr->stat_add[i]);
1460 if ((i == A_CHR) && (p_ptr->muta3 & MUT3_ILL_NORM))
1462 /* 10 to 18/90 charisma, guaranteed, based on level */
1463 if (use < 8 + 2 * p_ptr->lev)
1465 use = 8 + 2 * p_ptr->lev;
1469 /* Notice changes */
1470 if (p_ptr->stat_use[i] != use)
1472 /* Save the new value */
1473 p_ptr->stat_use[i] = (s16b)use;
1475 /* Redisplay the stats later */
1476 p_ptr->redraw |= (PR_STATS);
1478 p_ptr->window |= (PW_PLAYER);
1482 /* Values: 3, 4, ..., 17 */
1483 if (use <= 18) ind = (use - 3);
1485 /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
1486 else if (use <= 18 + 219) ind = (15 + (use - 18) / 10);
1488 /* Range: 18/220+ */
1491 /* Notice changes */
1492 if (p_ptr->stat_ind[i] != ind)
1494 /* Save the new index */
1495 p_ptr->stat_ind[i] = (s16b)ind;
1497 /* Change in CON affects Hitpoints */
1500 p_ptr->update |= (PU_HP);
1503 /* Change in INT may affect Mana/Spells */
1504 else if (i == A_INT)
1506 if (mp_ptr->spell_stat == A_INT)
1508 p_ptr->update |= (PU_MANA | PU_SPELLS);
1512 /* Change in WIS may affect Mana/Spells */
1513 else if (i == A_WIS)
1515 if (mp_ptr->spell_stat == A_WIS)
1517 p_ptr->update |= (PU_MANA | PU_SPELLS);
1521 /* Change in WIS may affect Mana/Spells */
1522 else if (i == A_CHR)
1524 if (mp_ptr->spell_stat == A_CHR)
1526 p_ptr->update |= (PU_MANA | PU_SPELLS);
1530 p_ptr->window |= (PW_PLAYER);
1535 /* Apply temporary "stun" */
1536 if (p_ptr->stun > 50)
1538 p_ptr->to_h[0] -= 20;
1539 p_ptr->to_h[1] -= 20;
1540 p_ptr->to_h_b -= 20;
1541 p_ptr->to_h_m -= 20;
1542 p_ptr->dis_to_h[0] -= 20;
1543 p_ptr->dis_to_h[1] -= 20;
1544 p_ptr->dis_to_h_b -= 20;
1545 p_ptr->to_d[0] -= 20;
1546 p_ptr->to_d[1] -= 20;
1547 p_ptr->to_d_m -= 20;
1548 p_ptr->dis_to_d[0] -= 20;
1549 p_ptr->dis_to_d[1] -= 20;
1551 else if (p_ptr->stun)
1553 p_ptr->to_h[0] -= 5;
1554 p_ptr->to_h[1] -= 5;
1557 p_ptr->dis_to_h[0] -= 5;
1558 p_ptr->dis_to_h[1] -= 5;
1559 p_ptr->dis_to_h_b -= 5;
1560 p_ptr->to_d[0] -= 5;
1561 p_ptr->to_d[1] -= 5;
1563 p_ptr->dis_to_d[0] -= 5;
1564 p_ptr->dis_to_d[1] -= 5;
1568 if (p_ptr->wraith_form)
1570 p_ptr->reflect = TRUE;
1571 p_ptr->pass_wall = TRUE;
1574 if (p_ptr->kabenuke)
1576 p_ptr->pass_wall = TRUE;
1579 /* Temporary blessing */
1583 p_ptr->dis_to_a += 5;
1584 p_ptr->to_h[0] += 10;
1585 p_ptr->to_h[1] += 10;
1586 p_ptr->to_h_b += 10;
1587 p_ptr->to_h_m += 10;
1588 p_ptr->dis_to_h[0] += 10;
1589 p_ptr->dis_to_h[1] += 10;
1590 p_ptr->dis_to_h_b += 10;
1593 if (p_ptr->magicdef)
1595 p_ptr->resist_blind = TRUE;
1596 p_ptr->resist_conf = TRUE;
1597 p_ptr->reflect = TRUE;
1598 p_ptr->free_act = TRUE;
1599 p_ptr->levitation = TRUE;
1602 /* Temporary "Hero" */
1605 p_ptr->to_h[0] += 12;
1606 p_ptr->to_h[1] += 12;
1607 p_ptr->to_h_b += 12;
1608 p_ptr->to_h_m += 12;
1609 p_ptr->dis_to_h[0] += 12;
1610 p_ptr->dis_to_h[1] += 12;
1611 p_ptr->dis_to_h_b += 12;
1614 /* Temporary "Beserk" */
1617 p_ptr->to_h[0] += 12;
1618 p_ptr->to_h[1] += 12;
1619 p_ptr->to_h_b -= 12;
1620 p_ptr->to_h_m += 12;
1621 p_ptr->to_d[0] += 3 + (p_ptr->lev / 5);
1622 p_ptr->to_d[1] += 3 + (p_ptr->lev / 5);
1623 p_ptr->to_d_m += 3 + (p_ptr->lev / 5);
1624 p_ptr->dis_to_h[0] += 12;
1625 p_ptr->dis_to_h[1] += 12;
1626 p_ptr->dis_to_h_b -= 12;
1627 p_ptr->dis_to_d[0] += 3 + (p_ptr->lev / 5);
1628 p_ptr->dis_to_d[1] += 3 + (p_ptr->lev / 5);
1630 p_ptr->dis_to_a -= 10;
1631 p_ptr->skill_stl -= 7;
1632 p_ptr->skill_dev -= 20;
1633 p_ptr->skill_sav -= 30;
1634 p_ptr->skill_srh -= 15;
1635 p_ptr->skill_fos -= 15;
1636 p_ptr->skill_tht -= 20;
1637 p_ptr->skill_dig += 30;
1640 /* Temporary "fast" */
1646 /* Temporary "slow" */
1652 /* Temporary "telepathy" */
1655 p_ptr->telepathy = TRUE;
1658 if (p_ptr->ele_immune)
1660 if (p_ptr->special_defense & DEFENSE_ACID)
1661 p_ptr->immune_acid = TRUE;
1662 else if (p_ptr->special_defense & DEFENSE_ELEC)
1663 p_ptr->immune_elec = TRUE;
1664 else if (p_ptr->special_defense & DEFENSE_FIRE)
1665 p_ptr->immune_fire = TRUE;
1666 else if (p_ptr->special_defense & DEFENSE_COLD)
1667 p_ptr->immune_cold = TRUE;
1670 /* Temporary see invisible */
1671 if (p_ptr->tim_invis)
1673 p_ptr->see_inv = TRUE;
1676 /* Temporary infravision boost */
1677 if (p_ptr->tim_infra)
1679 p_ptr->see_infra += 3;
1682 /* Temporary regeneration boost */
1683 if (p_ptr->tim_regen)
1685 p_ptr->regenerate = TRUE;
1688 /* Temporary levitation */
1689 if (p_ptr->tim_levitation)
1691 p_ptr->levitation = TRUE;
1694 /* Temporary reflection */
1695 if (p_ptr->tim_reflect)
1697 p_ptr->reflect = TRUE;
1700 /* Hack -- Hero/Shero -> Res fear */
1701 if (IS_HERO() || p_ptr->shero)
1703 p_ptr->resist_fear = TRUE;
1707 /* Hack -- Telepathy Change */
1708 if (p_ptr->telepathy != old_telepathy)
1710 p_ptr->update |= (PU_MONSTERS);
1713 if ((p_ptr->esp_animal != old_esp_animal) ||
1714 (p_ptr->esp_undead != old_esp_undead) ||
1715 (p_ptr->esp_demon != old_esp_demon) ||
1716 (p_ptr->esp_orc != old_esp_orc) ||
1717 (p_ptr->esp_troll != old_esp_troll) ||
1718 (p_ptr->esp_giant != old_esp_giant) ||
1719 (p_ptr->esp_dragon != old_esp_dragon) ||
1720 (p_ptr->esp_human != old_esp_human) ||
1721 (p_ptr->esp_evil != old_esp_evil) ||
1722 (p_ptr->esp_good != old_esp_good) ||
1723 (p_ptr->esp_nonliving != old_esp_nonliving) ||
1724 (p_ptr->esp_unique != old_esp_unique))
1726 p_ptr->update |= (PU_MONSTERS);
1729 /* Hack -- See Invis Change */
1730 if (p_ptr->see_inv != old_see_inv)
1732 p_ptr->update |= (PU_MONSTERS);
1735 /* Bloating slows the player down (a little) */
1736 if (p_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
1738 if (p_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
1740 if ((p_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
1741 (p_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
1743 p_ptr->to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
1744 p_ptr->dis_to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
1747 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
1749 int penalty1, penalty2;
1750 penalty1 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_RARM].weight) / 8);
1751 penalty2 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_LARM].weight) / 8);
1752 if ((inventory[INVEN_RARM].name1 == ART_QUICKTHORN) && (inventory[INVEN_LARM].name1 == ART_TINYTHORN))
1754 penalty1 = penalty1 / 2 - 5;
1755 penalty2 = penalty2 / 2 - 5;
1758 p_ptr->dis_to_a += 10;
1762 if (penalty1 > 0) penalty1 /= 2;
1763 if (penalty2 > 0) penalty2 /= 2;
1765 else if ((inventory[INVEN_LARM].tval == TV_SWORD) && ((inventory[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (inventory[INVEN_LARM].sval == SV_WAKIZASHI)))
1767 penalty1 = MAX(0, penalty1 - 10);
1768 penalty2 = MAX(0, penalty2 - 10);
1770 if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
1772 penalty1 = MIN(0, penalty1);
1773 penalty2 = MIN(0, penalty2);
1775 p_ptr->dis_to_a += 10;
1779 if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
1781 if ((inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
1784 if (inventory[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
1785 if (inventory[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
1786 p_ptr->to_h[0] -= (s16b)penalty1;
1787 p_ptr->to_h[1] -= (s16b)penalty2;
1788 p_ptr->dis_to_h[0] -= (s16b)penalty1;
1789 p_ptr->dis_to_h[1] -= (s16b)penalty2;
1792 /* Extract the current weight (in tenth pounds) */
1793 j = p_ptr->total_weight;
1797 /* Extract the "weight limit" (in tenth pounds) */
1798 i = (int)weight_limit();
1802 monster_type *riding_m_ptr = &m_list[p_ptr->riding];
1803 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
1804 SPEED speed = riding_m_ptr->mspeed;
1806 if (riding_m_ptr->mspeed > 110)
1808 new_speed = 110 + (s16b)((speed - 110) * (p_ptr->skill_exp[GINOU_RIDING] * 3 + p_ptr->lev * 160L - 10000L) / (22000L));
1809 if (new_speed < 110) new_speed = 110;
1815 new_speed += (p_ptr->skill_exp[GINOU_RIDING] + p_ptr->lev * 160L) / 3200;
1816 if (MON_FAST(riding_m_ptr)) new_speed += 10;
1817 if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
1818 riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
1819 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
1821 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) p_ptr->pass_wall = FALSE;
1822 if (riding_r_ptr->flags2 & RF2_KILL_WALL) p_ptr->kill_wall = TRUE;
1824 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;
1826 /* Extract the "weight limit" */
1827 i = 1500 + riding_r_ptr->level * 25;
1830 /* Apply "encumbrance" from weight */
1831 if (j > i) new_speed -= ((j - i) / (i / 5));
1833 /* Searching slows the player down */
1834 if (p_ptr->action == ACTION_SEARCH) new_speed -= 10;
1837 if (p_ptr->prace == RACE_MERFOLK)
1839 if (have_flag(f_ptr->flags, FF_WATER))
1841 new_speed += (2 + p_ptr->lev / 10);
1843 else if (!p_ptr->levitation)
1850 /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
1851 p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
1852 p_ptr->to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1853 p_ptr->to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1854 p_ptr->to_d_m += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1855 p_ptr->to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1856 p_ptr->to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1857 p_ptr->to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1858 p_ptr->to_h_m += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1859 p_ptr->to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1860 p_ptr->to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1861 p_ptr->to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1862 p_ptr->to_h_m += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1864 /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
1865 p_ptr->dis_to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
1866 p_ptr->dis_to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1867 p_ptr->dis_to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1868 p_ptr->dis_to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1869 p_ptr->dis_to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1870 p_ptr->dis_to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1871 p_ptr->dis_to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1872 p_ptr->dis_to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1873 p_ptr->dis_to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1876 /* Obtain the "hold" value */
1877 hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
1880 /* Examine the "current bow" */
1881 o_ptr = &inventory[INVEN_BOW];
1883 /* It is hard to carholdry a heavy bow */
1884 p_ptr->heavy_shoot = is_heavy_shoot(o_ptr);
1885 if (p_ptr->heavy_shoot)
1887 /* Hard to wield a heavy bow */
1888 p_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
1889 p_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
1892 /* Compute "extra shots" if needed */
1895 p_ptr->tval_ammo = (byte_hack)bow_tval_ammo(o_ptr);
1897 /* Apply special flags */
1898 if (o_ptr->k_idx && !p_ptr->heavy_shoot)
1901 p_ptr->num_fire = calc_num_fire(o_ptr);
1903 /* Snipers love Cross bows */
1904 if ((p_ptr->pclass == CLASS_SNIPER) &&
1905 (p_ptr->tval_ammo == TV_BOLT))
1907 p_ptr->to_h_b += (10 + (p_ptr->lev / 5));
1908 p_ptr->dis_to_h_b += (10 + (p_ptr->lev / 5));
1913 if (p_ptr->ryoute) hold *= 2;
1915 for (i = 0; i < 2; i++)
1917 /* Examine the "main weapon" */
1918 o_ptr = &inventory[INVEN_RARM + i];
1920 object_flags(o_ptr, flgs);
1922 /* Assume not heavy */
1923 p_ptr->heavy_wield[i] = FALSE;
1924 p_ptr->icky_wield[i] = FALSE;
1925 p_ptr->riding_wield[i] = FALSE;
1927 if (!buki_motteruka(INVEN_RARM + i))
1929 p_ptr->num_blow[i] = 1;
1932 /* It is hard to hold a heavy weapon */
1933 if (hold < o_ptr->weight / 10)
1935 /* Hard to wield a heavy weapon */
1936 p_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
1937 p_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
1940 p_ptr->heavy_wield[i] = TRUE;
1942 else if (p_ptr->ryoute && (hold < o_ptr->weight / 5)) omoi = TRUE;
1944 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
1947 p_ptr->dis_to_a += 5;
1950 /* Normal weapons */
1951 if (o_ptr->k_idx && !p_ptr->heavy_wield[i])
1953 int str_index, dex_index;
1955 int num = 0, wgt = 0, mul = 0, div = 0;
1957 /* Analyze the class */
1958 switch (p_ptr->pclass)
1962 num = 6; wgt = 70; mul = 5; break;
1965 case CLASS_BERSERKER:
1966 num = 6; wgt = 70; mul = 7; break;
1970 case CLASS_HIGH_MAGE:
1971 case CLASS_BLUE_MAGE:
1972 num = 3; wgt = 100; mul = 2; break;
1974 /* Priest, Mindcrafter, Magic-Eater */
1976 case CLASS_MAGIC_EATER:
1977 case CLASS_MINDCRAFTER:
1978 num = 5; wgt = 100; mul = 3; break;
1982 num = 5; wgt = 40; mul = 3; break;
1986 num = 5; wgt = 70; mul = 4; break;
1991 num = 5; wgt = 70; mul = 4; break;
1995 num = 5; wgt = 150; mul = 5; break;
1998 case CLASS_WARRIOR_MAGE:
1999 case CLASS_RED_MAGE:
2000 num = 5; wgt = 70; mul = 3; break;
2003 case CLASS_CHAOS_WARRIOR:
2004 num = 5; wgt = 70; mul = 4; break;
2008 num = 5; wgt = 60; mul = 3; break;
2012 num = 4; wgt = 100; mul = 3; break;
2015 case CLASS_IMITATOR:
2016 num = 5; wgt = 70; mul = 4; break;
2019 case CLASS_BEASTMASTER:
2020 num = 5; wgt = 70; mul = 3; break;
2024 if ((p_ptr->riding) && (have_flag(flgs, TR_RIDING))) { num = 5; wgt = 70; mul = 4; }
2025 else { num = 5; wgt = 100; mul = 3; }
2029 case CLASS_SORCERER:
2030 num = 1; wgt = 1; mul = 1; break;
2032 /* Archer, Bard, Sniper */
2036 num = 4; wgt = 70; mul = 2; break;
2039 case CLASS_FORCETRAINER:
2040 num = 4; wgt = 60; mul = 2; break;
2043 case CLASS_MIRROR_MASTER:
2044 num = 3; wgt = 100; mul = 3; break;
2048 num = 4; wgt = 20; mul = 1; break;
2051 /* Hex - extra mights gives +1 bonus to max blows */
2052 if (hex_spelling(HEX_XTRA_MIGHT) || hex_spelling(HEX_BUILDING)) { num++; wgt /= 2; mul += 2; }
2054 /* Enforce a minimum "weight" (tenth pounds) */
2055 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
2057 /* Access the strength vs weight */
2058 str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * mul / div);
2060 if (p_ptr->ryoute && !omoi) str_index++;
2061 if (p_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index - 1);
2064 if (str_index > 11) str_index = 11;
2066 /* Index by dexterity */
2067 dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]);
2070 if (dex_index > 11) dex_index = 11;
2072 /* Use the blows table */
2073 p_ptr->num_blow[i] = blows_table[str_index][dex_index];
2076 if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = (s16b)num;
2078 /* Add in the "bonus blows" */
2079 p_ptr->num_blow[i] += (s16b)extra_blows[i];
2082 if (p_ptr->pclass == CLASS_WARRIOR) p_ptr->num_blow[i] += (p_ptr->lev / 40);
2083 else if (p_ptr->pclass == CLASS_BERSERKER)
2085 p_ptr->num_blow[i] += (p_ptr->lev / 23);
2087 else if ((p_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (p_ptr->stat_ind[A_DEX] >= 30)) p_ptr->num_blow[i] ++;
2089 if (p_ptr->special_defense & KATA_FUUJIN) p_ptr->num_blow[i] -= 1;
2091 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) p_ptr->num_blow[i] = 1;
2094 /* Require at least one blow */
2095 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
2097 /* Boost digging skill by weapon weight */
2098 p_ptr->skill_dig += (o_ptr->weight / 10);
2102 /* Priest weapon penalty for non-blessed edged weapons */
2103 if ((p_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
2104 ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
2106 /* Reduce the real bonuses */
2107 p_ptr->to_h[i] -= 2;
2108 p_ptr->to_d[i] -= 2;
2110 /* Reduce the mental bonuses */
2111 p_ptr->dis_to_h[i] -= 2;
2112 p_ptr->dis_to_d[i] -= 2;
2115 p_ptr->icky_wield[i] = TRUE;
2117 else if (p_ptr->pclass == CLASS_BERSERKER)
2119 p_ptr->to_h[i] += p_ptr->lev / 5;
2120 p_ptr->to_d[i] += p_ptr->lev / 6;
2121 p_ptr->dis_to_h[i] += p_ptr->lev / 5;
2122 p_ptr->dis_to_d[i] += p_ptr->lev / 6;
2123 if (((i == 0) && !p_ptr->hidarite) || p_ptr->ryoute)
2125 p_ptr->to_h[i] += p_ptr->lev / 5;
2126 p_ptr->to_d[i] += p_ptr->lev / 6;
2127 p_ptr->dis_to_h[i] += p_ptr->lev / 5;
2128 p_ptr->dis_to_d[i] += p_ptr->lev / 6;
2131 else if (p_ptr->pclass == CLASS_SORCERER)
2133 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
2135 /* Reduce the real bonuses */
2136 p_ptr->to_h[i] -= 200;
2137 p_ptr->to_d[i] -= 200;
2139 /* Reduce the mental bonuses */
2140 p_ptr->dis_to_h[i] -= 200;
2141 p_ptr->dis_to_d[i] -= 200;
2144 p_ptr->icky_wield[i] = TRUE;
2148 /* Reduce the real bonuses */
2149 p_ptr->to_h[i] -= 30;
2150 p_ptr->to_d[i] -= 10;
2152 /* Reduce the mental bonuses */
2153 p_ptr->dis_to_h[i] -= 30;
2154 p_ptr->dis_to_d[i] -= 10;
2158 if (p_ptr->realm1 == REALM_HEX)
2160 if (object_is_cursed(o_ptr))
2162 if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
2163 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_h[i] += 7; p_ptr->dis_to_h[i] += 7; }
2164 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_h[i] += 13; p_ptr->dis_to_h[i] += 13; }
2165 if (o_ptr->curse_flags & (TRC_TY_CURSE)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
2166 if (hex_spelling(HEX_RUNESWORD))
2168 if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_d[i] += 5; p_ptr->dis_to_d[i] += 5; }
2169 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_d[i] += 7; p_ptr->dis_to_d[i] += 7; }
2170 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_d[i] += 13; p_ptr->dis_to_d[i] += 13; }
2176 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2178 p_ptr->to_h[i] += 15;
2179 p_ptr->dis_to_h[i] += 15;
2180 p_ptr->to_dd[i] += 2;
2182 else if (!(have_flag(flgs, TR_RIDING)))
2185 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
2191 penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
2193 if (penalty < 30) penalty = 30;
2195 p_ptr->to_h[i] -= (s16b)penalty;
2196 p_ptr->dis_to_h[i] -= (s16b)penalty;
2199 p_ptr->riding_wield[i] = TRUE;
2208 p_ptr->riding_ryoute = FALSE;
2210 if (p_ptr->ryoute || (empty_hands(FALSE) == EMPTY_HAND_NONE)) p_ptr->riding_ryoute = TRUE;
2211 else if (p_ptr->pet_extra_flags & PF_RYOUTE)
2213 switch (p_ptr->pclass)
2216 case CLASS_FORCETRAINER:
2217 case CLASS_BERSERKER:
2218 if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
2219 p_ptr->riding_ryoute = TRUE;
2224 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
2226 if (p_ptr->tval_ammo != TV_ARROW) penalty = 5;
2230 penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
2232 if (penalty < 30) penalty = 30;
2234 if (p_ptr->tval_ammo == TV_BOLT) penalty *= 2;
2235 p_ptr->to_h_b -= (s16b)penalty;
2236 p_ptr->dis_to_h_b -= (s16b)penalty;
2239 /* Different calculation for monks with empty hands */
2240 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) &&
2241 (empty_hands_status & EMPTY_HAND_RARM) && !p_ptr->hidarite)
2243 int blow_base = p_ptr->lev + adj_dex_blow[p_ptr->stat_ind[A_DEX]];
2244 p_ptr->num_blow[0] = 0;
2246 if (p_ptr->pclass == CLASS_FORCETRAINER)
2248 if (blow_base > 18) p_ptr->num_blow[0]++;
2249 if (blow_base > 31) p_ptr->num_blow[0]++;
2250 if (blow_base > 44) p_ptr->num_blow[0]++;
2251 if (blow_base > 58) p_ptr->num_blow[0]++;
2254 p_ptr->to_d[0] += P_PTR_KI / 5;
2255 p_ptr->dis_to_d[0] += P_PTR_KI / 5;
2260 if (blow_base > 12) p_ptr->num_blow[0]++;
2261 if (blow_base > 22) p_ptr->num_blow[0]++;
2262 if (blow_base > 31) p_ptr->num_blow[0]++;
2263 if (blow_base > 39) p_ptr->num_blow[0]++;
2264 if (blow_base > 46) p_ptr->num_blow[0]++;
2265 if (blow_base > 53) p_ptr->num_blow[0]++;
2266 if (blow_base > 59) p_ptr->num_blow[0]++;
2269 if (heavy_armor() && (p_ptr->pclass != CLASS_BERSERKER))
2270 p_ptr->num_blow[0] /= 2;
2273 p_ptr->to_h[0] += (p_ptr->lev / 3);
2274 p_ptr->dis_to_h[0] += (p_ptr->lev / 3);
2276 p_ptr->to_d[0] += (p_ptr->lev / 6);
2277 p_ptr->dis_to_d[0] += (p_ptr->lev / 6);
2280 if (p_ptr->special_defense & KAMAE_BYAKKO)
2283 p_ptr->dis_to_a -= 40;
2286 else if (p_ptr->special_defense & KAMAE_SEIRYU)
2289 p_ptr->dis_to_a -= 50;
2290 p_ptr->resist_acid = TRUE;
2291 p_ptr->resist_fire = TRUE;
2292 p_ptr->resist_elec = TRUE;
2293 p_ptr->resist_cold = TRUE;
2294 p_ptr->resist_pois = TRUE;
2295 p_ptr->sh_fire = TRUE;
2296 p_ptr->sh_elec = TRUE;
2297 p_ptr->sh_cold = TRUE;
2298 p_ptr->levitation = TRUE;
2300 else if (p_ptr->special_defense & KAMAE_GENBU)
2302 p_ptr->to_a += (p_ptr->lev*p_ptr->lev) / 50;
2303 p_ptr->dis_to_a += (p_ptr->lev*p_ptr->lev) / 50;
2304 p_ptr->reflect = TRUE;
2305 p_ptr->num_blow[0] -= 2;
2306 if ((p_ptr->pclass == CLASS_MONK) && (p_ptr->lev > 42)) p_ptr->num_blow[0]--;
2307 if (p_ptr->num_blow[0] < 0) p_ptr->num_blow[0] = 0;
2309 else if (p_ptr->special_defense & KAMAE_SUZAKU)
2311 p_ptr->to_h[0] -= (p_ptr->lev / 3);
2312 p_ptr->to_d[0] -= (p_ptr->lev / 6);
2314 p_ptr->dis_to_h[0] -= (p_ptr->lev / 3);
2315 p_ptr->dis_to_d[0] -= (p_ptr->lev / 6);
2316 p_ptr->num_blow[0] /= 2;
2317 p_ptr->levitation = TRUE;
2320 p_ptr->num_blow[0] += 1 + extra_blows[0];
2323 if (p_ptr->riding) p_ptr->levitation = riding_levitation;
2325 monk_armour_aux = FALSE;
2329 monk_armour_aux = TRUE;
2332 for (i = 0; i < 2; i++)
2334 if (buki_motteruka(INVEN_RARM + i))
2336 OBJECT_TYPE_VALUE tval = inventory[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
2337 OBJECT_SUBTYPE_VALUE sval = inventory[INVEN_RARM + i].sval;
2339 p_ptr->to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2340 p_ptr->dis_to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2341 if ((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER))
2343 if (!s_info[p_ptr->pclass].w_max[tval][sval])
2345 p_ptr->to_h[i] -= 40;
2346 p_ptr->dis_to_h[i] -= 40;
2347 p_ptr->icky_wield[i] = TRUE;
2350 else if (p_ptr->pclass == CLASS_NINJA)
2352 if ((s_info[CLASS_NINJA].w_max[tval][sval] <= WEAPON_EXP_BEGINNER) || (inventory[INVEN_LARM - i].tval == TV_SHIELD))
2354 p_ptr->to_h[i] -= 40;
2355 p_ptr->dis_to_h[i] -= 40;
2356 p_ptr->icky_wield[i] = TRUE;
2357 p_ptr->num_blow[i] /= 2;
2358 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
2362 if (inventory[INVEN_RARM + i].name1 == ART_IRON_BALL) p_ptr->align -= 1000;
2366 /* Maximum speed is (+99). (internally it's 110 + 99) */
2367 /* Temporary lightspeed forces to be maximum speed */
2368 if ((p_ptr->lightspeed && !p_ptr->riding) || (new_speed > 209))
2373 /* Minimum speed is (-99). (internally it's 110 - 99) */
2374 if (new_speed < 11) new_speed = 11;
2376 /* Display the speed (if needed) */
2377 if (p_ptr->pspeed != (byte)new_speed)
2379 p_ptr->pspeed = (byte)new_speed;
2380 p_ptr->redraw |= (PR_SPEED);
2385 if (p_ptr->to_a > (0 - p_ptr->ac))
2386 p_ptr->to_a = 0 - p_ptr->ac;
2387 if (p_ptr->dis_to_a > (0 - p_ptr->dis_ac))
2388 p_ptr->dis_to_a = 0 - p_ptr->dis_ac;
2391 /* Redraw armor (if needed) */
2392 if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
2394 p_ptr->redraw |= (PR_ARMOR);
2395 p_ptr->window |= (PW_PLAYER);
2398 if (p_ptr->ryoute && !omoi)
2400 int bonus_to_h = 0, bonus_to_d = 0;
2401 bonus_to_d = ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128) / 2;
2402 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);
2404 p_ptr->to_h[default_hand] += MAX(bonus_to_h, 1);
2405 p_ptr->dis_to_h[default_hand] += MAX(bonus_to_h, 1);
2406 p_ptr->to_d[default_hand] += MAX(bonus_to_d, 1);
2407 p_ptr->dis_to_d[default_hand] += MAX(bonus_to_d, 1);
2410 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))) p_ptr->ryoute = FALSE;
2412 /* Affect Skill -- stealth (bonus one) */
2413 p_ptr->skill_stl += 1;
2415 if (IS_TIM_STEALTH()) p_ptr->skill_stl += 99;
2417 /* Affect Skill -- disarming (DEX and INT) */
2418 p_ptr->skill_dis += adj_dex_dis[p_ptr->stat_ind[A_DEX]];
2419 p_ptr->skill_dis += adj_int_dis[p_ptr->stat_ind[A_INT]];
2421 /* Affect Skill -- magic devices (INT) */
2422 p_ptr->skill_dev += adj_int_dev[p_ptr->stat_ind[A_INT]];
2424 /* Affect Skill -- saving throw (WIS) */
2425 p_ptr->skill_sav += adj_wis_sav[p_ptr->stat_ind[A_WIS]];
2427 /* Affect Skill -- digging (STR) */
2428 p_ptr->skill_dig += adj_str_dig[p_ptr->stat_ind[A_STR]];
2430 /* Affect Skill -- disarming (Level, by Class) */
2431 p_ptr->skill_dis += ((cp_ptr->x_dis * p_ptr->lev / 10) + (ap_ptr->a_dis * p_ptr->lev / 50));
2433 /* Affect Skill -- magic devices (Level, by Class) */
2434 p_ptr->skill_dev += ((cp_ptr->x_dev * p_ptr->lev / 10) + (ap_ptr->a_dev * p_ptr->lev / 50));
2436 /* Affect Skill -- saving throw (Level, by Class) */
2437 p_ptr->skill_sav += ((cp_ptr->x_sav * p_ptr->lev / 10) + (ap_ptr->a_sav * p_ptr->lev / 50));
2439 /* Affect Skill -- stealth (Level, by Class) */
2440 p_ptr->skill_stl += (cp_ptr->x_stl * p_ptr->lev / 10);
2442 /* Affect Skill -- search ability (Level, by Class) */
2443 p_ptr->skill_srh += (cp_ptr->x_srh * p_ptr->lev / 10);
2445 /* Affect Skill -- search frequency (Level, by Class) */
2446 p_ptr->skill_fos += (cp_ptr->x_fos * p_ptr->lev / 10);
2448 /* Affect Skill -- combat (normal) (Level, by Class) */
2449 p_ptr->skill_thn += ((cp_ptr->x_thn * p_ptr->lev / 10) + (ap_ptr->a_thn * p_ptr->lev / 50));
2451 /* Affect Skill -- combat (shooting) (Level, by Class) */
2452 p_ptr->skill_thb += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
2454 /* Affect Skill -- combat (throwing) (Level, by Class) */
2455 p_ptr->skill_tht += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
2458 if ((prace_is_(RACE_S_FAIRY)) && (p_ptr->pseikaku != SEIKAKU_SEXY) && (p_ptr->cursed & TRC_AGGRAVATE))
2460 p_ptr->cursed &= ~(TRC_AGGRAVATE);
2461 p_ptr->skill_stl = MIN(p_ptr->skill_stl - 3, (p_ptr->skill_stl + 2) / 2);
2464 /* Limit Skill -- stealth from 0 to 30 */
2465 if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
2466 if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;
2468 /* Limit Skill -- digging from 1 up */
2469 if (p_ptr->skill_dig < 1) p_ptr->skill_dig = 1;
2471 if (p_ptr->anti_magic && (p_ptr->skill_sav < (90 + p_ptr->lev))) p_ptr->skill_sav = 90 + p_ptr->lev;
2473 if (p_ptr->tsubureru) p_ptr->skill_sav = 10;
2475 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;
2477 if (down_saving) p_ptr->skill_sav /= 2;
2479 /* Hack -- Each elemental immunity includes resistance */
2480 if (p_ptr->immune_acid) p_ptr->resist_acid = TRUE;
2481 if (p_ptr->immune_elec) p_ptr->resist_elec = TRUE;
2482 if (p_ptr->immune_fire) p_ptr->resist_fire = TRUE;
2483 if (p_ptr->immune_cold) p_ptr->resist_cold = TRUE;
2485 /* Determine player alignment */
2486 for (i = 0, j = 0; i < 8; i++)
2488 switch (p_ptr->vir_types[i])
2491 p_ptr->align += p_ptr->virtues[i] * 2;
2501 p_ptr->align -= p_ptr->virtues[i];
2504 p_ptr->align += p_ptr->virtues[i];
2509 for (i = 0; i < j; i++)
2511 if (p_ptr->align > 0)
2513 p_ptr->align -= p_ptr->virtues[neutral[i]] / 2;
2514 if (p_ptr->align < 0) p_ptr->align = 0;
2516 else if (p_ptr->align < 0)
2518 p_ptr->align += p_ptr->virtues[neutral[i]] / 2;
2519 if (p_ptr->align > 0) p_ptr->align = 0;
2523 /* Hack -- handle "xtra" mode */
2524 if (character_xtra) return;
2526 /* Take note when "heavy bow" changes */
2527 if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
2529 if (p_ptr->heavy_shoot)
2531 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
2533 else if (inventory[INVEN_BOW].k_idx)
2535 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
2539 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
2543 p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
2546 for (i = 0; i < 2; i++)
2548 /* Take note when "heavy weapon" changes */
2549 if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
2551 if (p_ptr->heavy_wield[i])
2553 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
2555 else if (buki_motteruka(INVEN_RARM + i))
2557 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
2559 else if (p_ptr->heavy_wield[1 - i])
2561 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
2565 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
2569 p_ptr->old_heavy_wield[i] = p_ptr->heavy_wield[i];
2572 /* Take note when "heavy weapon" changes */
2573 if (p_ptr->old_riding_wield[i] != p_ptr->riding_wield[i])
2575 if (p_ptr->riding_wield[i])
2577 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2579 else if (!p_ptr->riding)
2581 msg_print(_("この武器は徒歩で使いやすい。", "This weapon was not suitable for use while riding."));
2583 else if (buki_motteruka(INVEN_RARM + i))
2585 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2588 p_ptr->old_riding_wield[i] = p_ptr->riding_wield[i];
2591 /* Take note when "illegal weapon" changes */
2592 if (p_ptr->old_icky_wield[i] != p_ptr->icky_wield[i])
2594 if (p_ptr->icky_wield[i])
2596 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2599 chg_virtue(V_FAITH, -1);
2602 else if (buki_motteruka(INVEN_RARM + i))
2604 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2608 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2612 p_ptr->old_icky_wield[i] = p_ptr->icky_wield[i];
2616 if (p_ptr->riding && (p_ptr->old_riding_ryoute != p_ptr->riding_ryoute))
2618 if (p_ptr->riding_ryoute)
2621 msg_format("%s馬を操れない。", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2623 msg_print("You are using both hand for fighting, and you can't control a riding pet.");
2629 msg_format("%s馬を操れるようになった。", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2631 msg_print("You began to control riding pet with one hand.");
2635 p_ptr->old_riding_ryoute = p_ptr->riding_ryoute;
2638 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && (monk_armour_aux != monk_notify_aux))
2642 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2645 chg_virtue(V_HARMONY, -1);
2650 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2653 monk_notify_aux = monk_armour_aux;
2656 for (i = 0; i < INVEN_PACK; i++)
2659 if ((inventory[i].tval == TV_SORCERY_BOOK) && (inventory[i].sval == 2)) have_dd_s = TRUE;
2660 if ((inventory[i].tval == TV_TRUMP_BOOK) && (inventory[i].sval == 1)) have_dd_t = TRUE;
2662 if ((inventory[i].tval == TV_NATURE_BOOK) && (inventory[i].sval == 2)) have_sw = TRUE;
2663 if ((inventory[i].tval == TV_CRAFT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
2666 for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2668 o_ptr = &o_list[this_o_idx];
2670 /* Acquire next object */
2671 next_o_idx = o_ptr->next_o_idx;
2674 if ((o_ptr->tval == TV_SORCERY_BOOK) && (o_ptr->sval == 3)) have_dd_s = TRUE;
2675 if ((o_ptr->tval == TV_TRUMP_BOOK) && (o_ptr->sval == 1)) have_dd_t = TRUE;
2677 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
2678 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
2681 if (p_ptr->pass_wall && !p_ptr->kill_wall) p_ptr->no_flowed = TRUE;
2683 if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER)))
2685 const magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY - 1][SPELL_DD_S];
2686 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2689 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)))
2691 const magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP - 1][SPELL_DD_T];
2692 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2695 if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER)))
2697 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
2698 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2701 if (have_kabe && ((p_ptr->realm1 == REALM_CRAFT) || (p_ptr->realm2 == REALM_CRAFT) || (p_ptr->pclass == CLASS_SORCERER)))
2703 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_KABE];
2704 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2710 * @brief プレイヤーの最大HPを計算する /
2711 * Calculate the players (maximal) hit points
2712 * Adjust current hitpoints if necessary
2716 static void calc_hitpoints(void)
2721 /* Un-inflate "half-hitpoint bonus per level" value */
2722 bonus = ((int)(adj_con_mhp[p_ptr->stat_ind[A_CON]]) - 128) * p_ptr->lev / 4;
2724 /* Calculate hitpoints */
2725 mhp = p_ptr->player_hp[p_ptr->lev - 1];
2727 if (p_ptr->mimic_form)
2729 if (p_ptr->pclass == CLASS_SORCERER)
2730 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
2732 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
2733 mhp = mhp * tmp_hitdie / p_ptr->hitdie;
2736 if (p_ptr->pclass == CLASS_SORCERER)
2738 if (p_ptr->lev < 30)
2739 mhp = (mhp * (45 + p_ptr->lev) / 100);
2741 mhp = (mhp * 75 / 100);
2742 bonus = (bonus * 65 / 100);
2747 if (p_ptr->pclass == CLASS_BERSERKER)
2749 mhp = mhp * (110 + (((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 110)) / 100;
2752 /* Always have at least one hitpoint per level */
2753 if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1;
2755 /* Factor in the hero / superhero settings */
2756 if (IS_HERO()) mhp += 10;
2757 if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
2758 if (p_ptr->tsuyoshi) mhp += 50;
2760 /* Factor in the hex spell settings */
2761 if (hex_spelling(HEX_XTRA_MIGHT)) mhp += 15;
2762 if (hex_spelling(HEX_BUILDING)) mhp += 60;
2764 /* New maximum hitpoints */
2765 if (p_ptr->mhp != mhp)
2767 /* Enforce maximum */
2768 if (p_ptr->chp >= mhp)
2771 p_ptr->chp_frac = 0;
2775 /* レベルアップの時は上昇量を表示する */
2776 if ((level_up == 1) && (mhp > p_ptr->mhp))
2778 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - p_ptr->mhp));
2781 /* Save the new max-hitpoints */
2784 /* Display hitpoints (later) */
2785 p_ptr->redraw |= (PR_HP);
2787 p_ptr->window |= (PW_PLAYER);
2792 * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
2795 * SWD: Experimental modification: multiple light sources have additive effect.
2797 static void calc_torch(void)
2801 BIT_FLAGS flgs[TR_FLAG_SIZE];
2803 /* Assume no light */
2804 p_ptr->cur_lite = 0;
2806 /* Loop through all wielded items */
2807 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2809 o_ptr = &inventory[i];
2810 /* Skip empty slots */
2811 if (!o_ptr->k_idx) continue;
2813 if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
2816 if (o_ptr->name2 != EGO_LITE_DARKNESS)
2818 if (o_ptr->tval == TV_LITE)
2820 if ((o_ptr->sval == SV_LITE_TORCH) && !(o_ptr->xtra4 > 0)) continue;
2821 if ((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
2824 object_flags(o_ptr, flgs);
2826 /* calc the lite_radius */
2829 if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 1;
2830 if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 2;
2831 if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 3;
2832 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
2833 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
2834 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
2835 p_ptr->cur_lite += (s16b)rad;
2838 /* max radius is 14 (was 5) without rewriting other code -- */
2839 /* see cave.c:update_lite() and defines.h:LITE_MAX */
2840 if (d_info[dungeon_type].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
2841 p_ptr->cur_lite = 1;
2844 * check if the player doesn't have light radius,
2845 * but does weakly glow as an intrinsic.
2847 if (p_ptr->cur_lite <= 0 && p_ptr->lite) p_ptr->cur_lite++;
2849 if (p_ptr->cur_lite > 14) p_ptr->cur_lite = 14;
2850 if (p_ptr->cur_lite < 0) p_ptr->cur_lite = 0;
2852 /* end experimental mods */
2854 /* Notice changes in the "lite radius" */
2855 if (p_ptr->old_lite != p_ptr->cur_lite)
2857 /* Hack -- PU_MON_LITE for monsters' darkness */
2858 p_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
2860 /* Remember the old lite */
2861 p_ptr->old_lite = p_ptr->cur_lite;
2863 if ((p_ptr->cur_lite > 0) && (p_ptr->special_defense & NINJA_S_STEALTH))
2864 set_superstealth(FALSE);
2869 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
2870 * Calculate number of spells player should have, and forget,
2871 * or remember, spells until that number is properly reflected.
2874 * Note that this function induces various "status" messages,
2875 * which must be bypasses until the character is created.
2877 static void calc_spells(void)
2879 int i, j, k, levels;
2881 int num_boukyaku = 0;
2883 const magic_type *s_ptr;
2890 /* Hack -- must be literate */
2891 if (!mp_ptr->spell_book) return;
2893 /* Hack -- wait for creation */
2894 if (!character_generated) return;
2896 /* Hack -- handle "xtra" mode */
2897 if (character_xtra) return;
2899 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
2901 p_ptr->new_spells = 0;
2905 p = spell_category_name(mp_ptr->spell_book);
2907 /* Determine the number of spells allowed */
2908 levels = p_ptr->lev - mp_ptr->spell_first + 1;
2910 /* Hack -- no negative spells */
2911 if (levels < 0) levels = 0;
2913 /* Extract total allowed spells */
2914 num_allowed = (adj_mag_study[p_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
2916 if ((p_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
2920 if (p_ptr->pclass == CLASS_SAMURAI)
2924 else if (p_ptr->realm2 == REALM_NONE)
2926 num_allowed = (num_allowed + 1) / 2;
2927 if (num_allowed > (32 + bonus)) num_allowed = 32 + bonus;
2929 else if ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))
2931 if (num_allowed > (96 + bonus)) num_allowed = 96 + bonus;
2935 if (num_allowed > (80 + bonus)) num_allowed = 80 + bonus;
2938 /* Count the number of spells we know */
2939 for (j = 0; j < 64; j++)
2941 /* Count known spells */
2943 (p_ptr->spell_forgotten1 & (1L << j)) :
2944 (p_ptr->spell_forgotten2 & (1L << (j - 32))))
2950 /* See how many spells we must forget or may learn */
2951 p_ptr->new_spells = num_allowed + p_ptr->add_spells + num_boukyaku - p_ptr->learned_spells;
2953 /* Forget spells which are too hard */
2954 for (i = 63; i >= 0; i--)
2956 /* Efficiency -- all done */
2957 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
2959 /* Access the spell */
2960 j = p_ptr->spell_order[i];
2962 /* Skip non-spells */
2963 if (j >= 99) continue;
2967 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
2970 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
2972 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j % 32];
2975 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
2977 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][j % 32];
2979 /* Skip spells we are allowed to know */
2980 if (s_ptr->slevel <= p_ptr->lev) continue;
2984 (p_ptr->spell_learned1 & (1L << j)) :
2985 (p_ptr->spell_learned2 & (1L << (j - 32))))
2987 /* Mark as forgotten */
2990 p_ptr->spell_forgotten1 |= (1L << j);
2991 which = p_ptr->realm1;
2995 p_ptr->spell_forgotten2 |= (1L << (j - 32));
2996 which = p_ptr->realm2;
2999 /* No longer known */
3002 p_ptr->spell_learned1 &= ~(1L << j);
3003 which = p_ptr->realm1;
3007 p_ptr->spell_learned2 &= ~(1L << (j - 32));
3008 which = p_ptr->realm2;
3012 msg_format("%sの%sを忘れてしまった。", do_spell(which, j % 32, SPELL_NAME), p);
3014 msg_format("You have forgotten the %s of %s.", p, do_spell(which, j % 32, SPELL_NAME));
3018 /* One more can be learned */
3019 p_ptr->new_spells++;
3024 /* Forget spells if we know too many spells */
3025 for (i = 63; i >= 0; i--)
3027 /* Stop when possible */
3028 if (p_ptr->new_spells >= 0) break;
3030 /* Efficiency -- all done */
3031 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
3033 /* Get the (i+1)th spell learned */
3034 j = p_ptr->spell_order[i];
3036 /* Skip unknown spells */
3037 if (j >= 99) continue;
3039 /* Forget it (if learned) */
3041 (p_ptr->spell_learned1 & (1L << j)) :
3042 (p_ptr->spell_learned2 & (1L << (j - 32))))
3044 /* Mark as forgotten */
3047 p_ptr->spell_forgotten1 |= (1L << j);
3048 which = p_ptr->realm1;
3052 p_ptr->spell_forgotten2 |= (1L << (j - 32));
3053 which = p_ptr->realm2;
3056 /* No longer known */
3059 p_ptr->spell_learned1 &= ~(1L << j);
3060 which = p_ptr->realm1;
3064 p_ptr->spell_learned2 &= ~(1L << (j - 32));
3065 which = p_ptr->realm2;
3069 msg_format("%sの%sを忘れてしまった。",
3070 do_spell(which, j % 32, SPELL_NAME), p);
3072 msg_format("You have forgotten the %s of %s.", p,
3073 do_spell(which, j % 32, SPELL_NAME));
3077 /* One more can be learned */
3078 p_ptr->new_spells++;
3083 /* Check for spells to remember */
3084 for (i = 0; i < 64; i++)
3086 /* None left to remember */
3087 if (p_ptr->new_spells <= 0) break;
3089 /* Efficiency -- all done */
3090 if (!p_ptr->spell_forgotten1 && !p_ptr->spell_forgotten2) break;
3092 /* Get the next spell we learned */
3093 j = p_ptr->spell_order[i];
3095 /* Skip unknown spells */
3098 /* Access the spell */
3099 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
3102 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
3104 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j % 32];
3107 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
3109 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][j % 32];
3111 /* Skip spells we cannot remember */
3112 if (s_ptr->slevel > p_ptr->lev) continue;
3114 /* First set of spells */
3116 (p_ptr->spell_forgotten1 & (1L << j)) :
3117 (p_ptr->spell_forgotten2 & (1L << (j - 32))))
3119 /* No longer forgotten */
3122 p_ptr->spell_forgotten1 &= ~(1L << j);
3123 which = p_ptr->realm1;
3127 p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
3128 which = p_ptr->realm2;
3131 /* Known once more */
3134 p_ptr->spell_learned1 |= (1L << j);
3135 which = p_ptr->realm1;
3139 p_ptr->spell_learned2 |= (1L << (j - 32));
3140 which = p_ptr->realm2;
3144 msg_format("%sの%sを思い出した。", do_spell(which, j % 32, SPELL_NAME), p);
3146 msg_format("You have remembered the %s of %s.", p, do_spell(which, j % 32, SPELL_NAME));
3150 /* One less can be learned */
3151 p_ptr->new_spells--;
3157 if (p_ptr->realm2 == REALM_NONE)
3159 /* Count spells that can be learned */
3160 for (j = 0; j < 32; j++)
3162 if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
3163 else s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
3165 /* Skip spells we cannot remember */
3166 if (s_ptr->slevel > p_ptr->lev) continue;
3168 /* Skip spells we already know */
3169 if (p_ptr->spell_learned1 & (1L << j))
3178 if ((p_ptr->new_spells > k) &&
3179 ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
3181 p_ptr->new_spells = (s16b)k;
3185 if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
3187 /* Spell count changed */
3188 if (p_ptr->old_spells != p_ptr->new_spells)
3190 /* Message if needed */
3191 if (p_ptr->new_spells)
3194 if (p_ptr->new_spells < 10) {
3195 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
3198 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
3201 msg_format("You can learn %d more %s%s.",
3202 p_ptr->new_spells, p,
3203 (p_ptr->new_spells != 1) ? "s" : "");
3208 /* Save the new_spells value */
3209 p_ptr->old_spells = p_ptr->new_spells;
3211 /* Redraw Study Status */
3212 p_ptr->redraw |= (PR_STUDY);
3214 /* Redraw object recall */
3215 p_ptr->window |= (PW_OBJECT);
3220 * @brief プレイヤーの最大MPを計算する /
3221 * Calculate maximum mana. You do not need to know any spells.
3222 * Note that mana is lowered by heavy (or inappropriate) armor.
3225 * This function induces status messages.
3227 static void calc_mana(void)
3229 int msp, levels, cur_wgt, max_wgt;
3234 /* Hack -- Must be literate */
3235 if (!mp_ptr->spell_book) return;
3237 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3238 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3239 (p_ptr->pclass == CLASS_BLUE_MAGE))
3241 levels = p_ptr->lev;
3245 if (mp_ptr->spell_first > p_ptr->lev)
3250 /* Display mana later */
3251 p_ptr->redraw |= (PR_MANA);
3255 /* Extract "effective" player level */
3256 levels = (p_ptr->lev - mp_ptr->spell_first) + 1;
3259 if (p_ptr->pclass == CLASS_SAMURAI)
3261 msp = (adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
3262 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
3266 /* Extract total mana */
3267 msp = adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
3269 /* Hack -- usually add one mana */
3272 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
3274 if (msp && (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp / 2;
3276 /* Hack: High mages have a 25% mana bonus */
3277 if (msp && (p_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
3279 if (msp && (p_ptr->pclass == CLASS_SORCERER)) msp += msp * (25 + p_ptr->lev) / 100;
3282 /* Only mages are affected */
3283 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
3285 BIT_FLAGS flgs[TR_FLAG_SIZE];
3287 /* Assume player is not encumbered by gloves */
3288 p_ptr->cumber_glove = FALSE;
3290 /* Get the gloves */
3291 o_ptr = &inventory[INVEN_HANDS];
3293 /* Examine the gloves */
3294 object_flags(o_ptr, flgs);
3296 /* Normal gloves hurt mage-type spells */
3298 !(have_flag(flgs, TR_FREE_ACT)) &&
3299 !(have_flag(flgs, TR_DEC_MANA)) &&
3300 !(have_flag(flgs, TR_EASY_SPELL)) &&
3301 !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
3302 !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
3305 p_ptr->cumber_glove = TRUE;
3308 msp = (3 * msp) / 4;
3313 /* Assume player not encumbered by armor */
3314 p_ptr->cumber_armor = FALSE;
3316 /* Weigh the armor */
3318 if (inventory[INVEN_RARM].tval > TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
3319 if (inventory[INVEN_LARM].tval > TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
3320 cur_wgt += inventory[INVEN_BODY].weight;
3321 cur_wgt += inventory[INVEN_HEAD].weight;
3322 cur_wgt += inventory[INVEN_OUTER].weight;
3323 cur_wgt += inventory[INVEN_HANDS].weight;
3324 cur_wgt += inventory[INVEN_FEET].weight;
3326 /* Subtract a percentage of maximum mana. */
3327 switch (p_ptr->pclass)
3329 /* For these classes, mana is halved if armour
3330 * is 30 pounds over their weight limit. */
3332 case CLASS_HIGH_MAGE:
3333 case CLASS_BLUE_MAGE:
3335 case CLASS_FORCETRAINER:
3336 case CLASS_SORCERER:
3338 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
3339 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
3343 /* Mana halved if armour is 40 pounds over weight limit. */
3348 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight * 2 / 3;
3349 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight * 2 / 3;
3353 case CLASS_MINDCRAFTER:
3354 case CLASS_BEASTMASTER:
3355 case CLASS_MIRROR_MASTER:
3357 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight / 2;
3358 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight / 2;
3362 /* Mana halved if armour is 50 pounds over weight limit. */
3365 case CLASS_RED_MAGE:
3366 case CLASS_WARRIOR_MAGE:
3368 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight / 3;
3369 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight / 3;
3373 /* Mana halved if armour is 60 pounds over weight limit. */
3375 case CLASS_CHAOS_WARRIOR:
3377 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight / 5;
3378 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight / 5;
3382 /* For new classes created, but not yet added to this formula. */
3389 /* Determine the weight allowance */
3390 max_wgt = mp_ptr->spell_weight;
3392 /* Heavy armor penalizes mana by a percentage. -LM- */
3393 if ((cur_wgt - max_wgt) > 0)
3396 p_ptr->cumber_armor = TRUE;
3398 /* Subtract a percentage of maximum mana. */
3399 switch (p_ptr->pclass)
3401 /* For these classes, mana is halved if armour
3402 * is 30 pounds over their weight limit. */
3404 case CLASS_HIGH_MAGE:
3405 case CLASS_BLUE_MAGE:
3407 msp -= msp * (cur_wgt - max_wgt) / 600;
3411 /* Mana halved if armour is 40 pounds over weight limit. */
3413 case CLASS_MINDCRAFTER:
3414 case CLASS_BEASTMASTER:
3416 case CLASS_FORCETRAINER:
3418 case CLASS_MIRROR_MASTER:
3420 msp -= msp * (cur_wgt - max_wgt) / 800;
3424 case CLASS_SORCERER:
3426 msp -= msp * (cur_wgt - max_wgt) / 900;
3430 /* Mana halved if armour is 50 pounds over weight limit. */
3434 case CLASS_RED_MAGE:
3436 msp -= msp * (cur_wgt - max_wgt) / 1000;
3440 /* Mana halved if armour is 60 pounds over weight limit. */
3442 case CLASS_CHAOS_WARRIOR:
3443 case CLASS_WARRIOR_MAGE:
3445 msp -= msp * (cur_wgt - max_wgt) / 1200;
3451 p_ptr->cumber_armor = FALSE;
3455 /* For new classes created, but not yet added to this formula. */
3458 msp -= msp * (cur_wgt - max_wgt) / 800;
3464 /* Mana can never be negative */
3465 if (msp < 0) msp = 0;
3468 /* Maximum mana has changed */
3469 if (p_ptr->msp != msp)
3471 /* Enforce maximum */
3472 if ((p_ptr->csp >= msp) && (p_ptr->pclass != CLASS_SAMURAI))
3475 p_ptr->csp_frac = 0;
3479 /* レベルアップの時は上昇量を表示する */
3480 if ((level_up == 1) && (msp > p_ptr->msp))
3482 msg_format("最大マジック・ポイントが %d 増加した!", (msp - p_ptr->msp));
3488 /* Display mana later */
3489 p_ptr->redraw |= (PR_MANA);
3491 p_ptr->window |= (PW_PLAYER);
3492 p_ptr->window |= (PW_SPELL);
3496 /* Hack -- handle "xtra" mode */
3497 if (character_xtra) return;
3499 /* Take note when "glove state" changes */
3500 if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
3502 if (p_ptr->cumber_glove)
3504 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
3508 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
3512 p_ptr->old_cumber_glove = p_ptr->cumber_glove;
3516 /* Take note when "armor state" changes */
3517 if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
3519 if (p_ptr->cumber_armor)
3521 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
3525 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
3529 p_ptr->old_cumber_armor = p_ptr->cumber_armor;
3534 * @brief 装備中の射撃武器の威力倍率を返す /
3535 * calcurate the fire rate of target object
3536 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
3537 * @return 射撃倍率の値(100で1.00倍)
3539 s16b calc_num_fire(object_type *o_ptr)
3541 int extra_shots = 0;
3544 OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
3546 BIT_FLAGS flgs[TR_FLAG_SIZE];
3548 /* Scan the usable inventory */
3549 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3551 q_ptr = &inventory[i];
3553 /* Skip non-objects */
3554 if (!q_ptr->k_idx) continue;
3556 /* Do not apply current equip */
3557 if (i == INVEN_BOW) continue;
3559 /* Extract the item flags */
3560 object_flags(q_ptr, flgs);
3563 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
3566 object_flags(o_ptr, flgs);
3567 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
3569 if (o_ptr->k_idx && !is_heavy_shoot(o_ptr))
3573 num += (extra_shots * 100);
3575 /* Hack -- Rangers love Bows */
3576 if ((p_ptr->pclass == CLASS_RANGER) &&
3577 (tval_ammo == TV_ARROW))
3579 num += (p_ptr->lev * 4);
3582 if ((p_ptr->pclass == CLASS_CAVALRY) &&
3583 (tval_ammo == TV_ARROW))
3585 num += (p_ptr->lev * 3);
3588 if (p_ptr->pclass == CLASS_ARCHER)
3590 if (tval_ammo == TV_ARROW)
3591 num += ((p_ptr->lev * 5) + 50);
3592 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
3593 num += (p_ptr->lev * 4);
3597 * Addendum -- also "Reward" high level warriors,
3598 * with _any_ missile weapon -- TY
3600 if (p_ptr->pclass == CLASS_WARRIOR &&
3601 (tval_ammo <= TV_BOLT) &&
3602 (tval_ammo >= TV_SHOT))
3604 num += (p_ptr->lev * 2);
3606 if ((p_ptr->pclass == CLASS_ROGUE) &&
3607 (tval_ammo == TV_SHOT))
3609 num += (p_ptr->lev * 4);
3616 * @brief プレイヤーの所持重量制限を計算する /
3617 * Computes current weight limit.
3620 WEIGHT weight_limit(void)
3624 /* Weight limit based only on strength */
3625 i = (WEIGHT)adj_str_wgt[p_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
3626 if (p_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
3628 /* Return the result */
3633 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
3634 * @param i 判定する手のID(右手:0 左手:1)
3635 * @return 持っているならばTRUE
3637 bool buki_motteruka(int i)
3639 return ((inventory[i].k_idx && object_is_melee_weapon(&inventory[i])) ? TRUE : FALSE);
3643 * @brief プレイヤーの現在開いている手の状態を返す
3644 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
3645 * @return 開いている手のビットフラグ
3647 BIT_FLAGS16 empty_hands(bool riding_control)
3649 BIT_FLAGS16 status = EMPTY_HAND_NONE;
3651 if (!inventory[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
3652 if (!inventory[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
3654 if (riding_control && (status != EMPTY_HAND_NONE) && p_ptr->riding && !(p_ptr->pet_extra_flags & PF_RYOUTE))
3656 if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
3657 else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
3665 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
3666 * @return ペナルティが適用されるならばTRUE。
3668 bool heavy_armor(void)
3670 WEIGHT monk_arm_wgt = 0;
3672 if ((p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_NINJA)) return FALSE;
3674 /* Weight the armor */
3675 if (inventory[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_RARM].weight;
3676 if (inventory[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_LARM].weight;
3677 monk_arm_wgt += inventory[INVEN_BODY].weight;
3678 monk_arm_wgt += inventory[INVEN_HEAD].weight;
3679 monk_arm_wgt += inventory[INVEN_OUTER].weight;
3680 monk_arm_wgt += inventory[INVEN_HANDS].weight;
3681 monk_arm_wgt += inventory[INVEN_FEET].weight;
3683 return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));
3687 * @brief p_ptr->update のフラグに応じた更新をまとめて行う / Handle "p_ptr->update"
3689 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
3691 void update_creature(player_type *creature_ptr)
3693 if (!creature_ptr->update) return;
3695 /* Actually do auto-destroy */
3696 if (creature_ptr->update & (PU_AUTODESTROY))
3698 creature_ptr->update &= ~(PU_AUTODESTROY);
3699 autopick_delayed_alter();
3702 /* Combine the pack */
3703 if (creature_ptr->update & (PU_COMBINE))
3705 creature_ptr->update &= ~(PU_COMBINE);
3709 /* Reorder the pack */
3710 if (creature_ptr->update & (PU_REORDER))
3712 creature_ptr->update &= ~(PU_REORDER);
3716 if (creature_ptr->update & (PU_BONUS))
3718 creature_ptr->update &= ~(PU_BONUS);
3722 if (creature_ptr->update & (PU_TORCH))
3724 creature_ptr->update &= ~(PU_TORCH);
3728 if (creature_ptr->update & (PU_HP))
3730 creature_ptr->update &= ~(PU_HP);
3734 if (creature_ptr->update & (PU_MANA))
3736 creature_ptr->update &= ~(PU_MANA);
3740 if (creature_ptr->update & (PU_SPELLS))
3742 creature_ptr->update &= ~(PU_SPELLS);
3746 /* Character is not ready yet, no screen updates */
3747 if (!character_generated) return;
3749 /* Character is in "icky" mode, no screen updates */
3750 if (character_icky) return;
3752 if (creature_ptr->update & (PU_UN_LITE))
3754 creature_ptr->update &= ~(PU_UN_LITE);
3758 if (creature_ptr->update & (PU_UN_VIEW))
3760 creature_ptr->update &= ~(PU_UN_VIEW);
3764 if (creature_ptr->update & (PU_VIEW))
3766 creature_ptr->update &= ~(PU_VIEW);
3770 if (creature_ptr->update & (PU_LITE))
3772 creature_ptr->update &= ~(PU_LITE);
3777 if (creature_ptr->update & (PU_FLOW))
3779 creature_ptr->update &= ~(PU_FLOW);
3783 if (creature_ptr->update & (PU_DISTANCE))
3785 creature_ptr->update &= ~(PU_DISTANCE);
3787 /* Still need to call update_monsters(FALSE) after update_mon_lite() */
3788 /* creature_ptr->update &= ~(PU_MONSTERS); */
3790 update_monsters(TRUE);
3793 if (creature_ptr->update & (PU_MON_LITE))
3795 creature_ptr->update &= ~(PU_MON_LITE);
3800 * Mega-Hack -- Delayed visual update
3801 * Only used if update_view(), update_lite() or update_mon_lite() was called
3803 if (creature_ptr->update & (PU_DELAY_VIS))
3805 creature_ptr->update &= ~(PU_DELAY_VIS);
3806 delayed_visual_update();
3809 if (creature_ptr->update & (PU_MONSTERS))
3811 creature_ptr->update &= ~(PU_MONSTERS);
3812 update_monsters(FALSE);