2 #include "player-status.h"
6 #include "spells-status.h"
9 * Return alignment title
11 concptr your_alignment(void)
13 if (p_ptr->align > 150) return _("大善", "Lawful");
14 else if (p_ptr->align > 50) return _("中善", "Good");
15 else if (p_ptr->align > 10) return _("小善", "Neutral Good");
16 else if (p_ptr->align > -11) return _("中立", "Neutral");
17 else if (p_ptr->align > -51) return _("小悪", "Neutral Evil");
18 else if (p_ptr->align > -151) return _("中悪", "Evil");
19 else return _("大悪", "Chaotic");
24 * Return proficiency level of weapons and misc. skills (except riding)
26 int weapon_exp_level(int weapon_exp)
28 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
29 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
30 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
31 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
32 else return EXP_LEVEL_MASTER;
37 * Return proficiency level of riding
39 int riding_exp_level(int riding_exp)
41 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
42 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
43 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
44 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
45 else return EXP_LEVEL_MASTER;
50 * Return proficiency level of spells
52 int spell_exp_level(int spell_exp)
54 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
55 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
56 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
57 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
58 else return EXP_LEVEL_MASTER;
62 * @brief プレイヤーの全ステータスを更新する /
63 * Calculate the players current "state", taking into account
64 * not only race/class intrinsics, but also objects being worn
65 * and temporary spell effects.
69 * See also calc_mana() and calc_hitpoints().
71 * Take note of the new "speed code", in particular, a very strong
72 * player will start slowing down as soon as he reaches 150 pounds,
73 * but not until he reaches 450 pounds will he be half as fast as
74 * a normal kobold. This both hurts and helps the player, hurts
75 * because in the old days a player could just avoid 300 pounds,
76 * and helps because now carrying 300 pounds is not very painful.
78 * The "weapon" and "bow" do *not* add to the bonuses to hit or to
79 * damage, since that would affect non-combat things. These values
80 * are actually added in later, at the appropriate place.
82 * This function induces various "status" messages.
85 void calc_bonuses(void)
87 int i, j, hold, neutral[2];
90 int empty_hands_status = empty_hands(TRUE);
93 BIT_FLAGS flgs[TR_FLAG_SIZE];
96 bool down_saving = FALSE;
98 bool have_dd_s = FALSE, have_dd_t = FALSE;
100 bool have_sw = FALSE, have_kabe = FALSE;
101 bool easy_2weapon = FALSE;
102 bool riding_levitation = FALSE;
103 OBJECT_IDX this_o_idx, next_o_idx = 0;
104 const player_race *tmp_rp_ptr;
106 /* Save the old vision stuff */
107 bool old_telepathy = p_ptr->telepathy;
108 bool old_esp_animal = p_ptr->esp_animal;
109 bool old_esp_undead = p_ptr->esp_undead;
110 bool old_esp_demon = p_ptr->esp_demon;
111 bool old_esp_orc = p_ptr->esp_orc;
112 bool old_esp_troll = p_ptr->esp_troll;
113 bool old_esp_giant = p_ptr->esp_giant;
114 bool old_esp_dragon = p_ptr->esp_dragon;
115 bool old_esp_human = p_ptr->esp_human;
116 bool old_esp_evil = p_ptr->esp_evil;
117 bool old_esp_good = p_ptr->esp_good;
118 bool old_esp_nonliving = p_ptr->esp_nonliving;
119 bool old_esp_unique = p_ptr->esp_unique;
120 bool old_see_inv = p_ptr->see_inv;
121 bool old_mighty_throw = p_ptr->mighty_throw;
123 /* Current feature under player. */
124 feature_type *f_ptr = &f_info[grid_array[p_ptr->y][p_ptr->x].feat];
126 /* Save the old armor class */
127 ARMOUR_CLASS old_dis_ac = p_ptr->dis_ac;
128 ARMOUR_CLASS old_dis_to_a = p_ptr->dis_to_a;
131 /* Clear extra blows/shots */
132 extra_blows[0] = extra_blows[1] = 0;
134 /* Clear the stat modifiers */
135 for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] = 0;
138 /* Clear the Displayed/Real armor class */
139 p_ptr->dis_ac = p_ptr->ac = 0;
141 /* Clear the Displayed/Real Bonuses */
142 p_ptr->dis_to_h[0] = p_ptr->to_h[0] = 0;
143 p_ptr->dis_to_h[1] = p_ptr->to_h[1] = 0;
144 p_ptr->dis_to_d[0] = p_ptr->to_d[0] = 0;
145 p_ptr->dis_to_d[1] = p_ptr->to_d[1] = 0;
146 p_ptr->dis_to_h_b = p_ptr->to_h_b = 0;
147 p_ptr->dis_to_a = p_ptr->to_a = 0;
151 p_ptr->to_m_chance = 0;
153 /* Clear the Extra Dice Bonuses */
154 p_ptr->to_dd[0] = p_ptr->to_ds[0] = 0;
155 p_ptr->to_dd[1] = p_ptr->to_ds[1] = 0;
157 /* Start with "normal" speed */
160 /* Start with a single blow per turn */
161 p_ptr->num_blow[0] = 1;
162 p_ptr->num_blow[1] = 1;
164 /* Start with a single shot per turn */
165 p_ptr->num_fire = 100;
167 /* Reset the "xtra" tval */
168 p_ptr->tval_xtra = 0;
170 /* Reset the "ammo" tval */
171 p_ptr->tval_ammo = 0;
173 /* Clear all the flags */
175 p_ptr->bless_blade = FALSE;
176 p_ptr->xtra_might = FALSE;
177 p_ptr->impact[0] = FALSE;
178 p_ptr->impact[1] = FALSE;
179 p_ptr->pass_wall = FALSE;
180 p_ptr->kill_wall = FALSE;
181 p_ptr->dec_mana = FALSE;
182 p_ptr->easy_spell = FALSE;
183 p_ptr->heavy_spell = FALSE;
184 p_ptr->see_inv = FALSE;
185 p_ptr->free_act = FALSE;
186 p_ptr->slow_digest = FALSE;
187 p_ptr->regenerate = FALSE;
188 p_ptr->can_swim = FALSE;
189 p_ptr->levitation = FALSE;
190 p_ptr->hold_exp = FALSE;
191 p_ptr->telepathy = FALSE;
192 p_ptr->esp_animal = FALSE;
193 p_ptr->esp_undead = FALSE;
194 p_ptr->esp_demon = FALSE;
195 p_ptr->esp_orc = FALSE;
196 p_ptr->esp_troll = FALSE;
197 p_ptr->esp_giant = FALSE;
198 p_ptr->esp_dragon = FALSE;
199 p_ptr->esp_human = FALSE;
200 p_ptr->esp_evil = FALSE;
201 p_ptr->esp_good = FALSE;
202 p_ptr->esp_nonliving = FALSE;
203 p_ptr->esp_unique = FALSE;
205 p_ptr->sustain_str = FALSE;
206 p_ptr->sustain_int = FALSE;
207 p_ptr->sustain_wis = FALSE;
208 p_ptr->sustain_con = FALSE;
209 p_ptr->sustain_dex = FALSE;
210 p_ptr->sustain_chr = FALSE;
211 p_ptr->resist_acid = FALSE;
212 p_ptr->resist_elec = FALSE;
213 p_ptr->resist_fire = FALSE;
214 p_ptr->resist_cold = FALSE;
215 p_ptr->resist_pois = FALSE;
216 p_ptr->resist_conf = FALSE;
217 p_ptr->resist_sound = FALSE;
218 p_ptr->resist_lite = FALSE;
219 p_ptr->resist_dark = FALSE;
220 p_ptr->resist_chaos = FALSE;
221 p_ptr->resist_disen = FALSE;
222 p_ptr->resist_shard = FALSE;
223 p_ptr->resist_nexus = FALSE;
224 p_ptr->resist_blind = FALSE;
225 p_ptr->resist_neth = FALSE;
226 p_ptr->resist_time = FALSE;
227 p_ptr->resist_water = FALSE;
228 p_ptr->resist_fear = FALSE;
229 p_ptr->reflect = FALSE;
230 p_ptr->sh_fire = FALSE;
231 p_ptr->sh_elec = FALSE;
232 p_ptr->sh_cold = FALSE;
233 p_ptr->anti_magic = FALSE;
234 p_ptr->anti_tele = FALSE;
235 p_ptr->warning = FALSE;
236 p_ptr->mighty_throw = FALSE;
237 p_ptr->see_nocto = FALSE;
239 p_ptr->immune_acid = FALSE;
240 p_ptr->immune_elec = FALSE;
241 p_ptr->immune_fire = FALSE;
242 p_ptr->immune_cold = FALSE;
244 p_ptr->ryoute = FALSE;
245 p_ptr->migite = FALSE;
246 p_ptr->hidarite = FALSE;
247 p_ptr->no_flowed = FALSE;
249 p_ptr->align = friend_align;
251 if (p_ptr->mimic_form) tmp_rp_ptr = &mimic_info[p_ptr->mimic_form];
252 else tmp_rp_ptr = &race_info[p_ptr->prace];
254 /* Base infravision (purely racial) */
255 p_ptr->see_infra = tmp_rp_ptr->infra;
257 /* Base skill -- disarming */
258 p_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
260 /* Base skill -- magic devices */
261 p_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
263 /* Base skill -- saving throw */
264 p_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
266 /* Base skill -- stealth */
267 p_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
269 /* Base skill -- searching ability */
270 p_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
272 /* Base skill -- searching frequency */
273 p_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
275 /* Base skill -- combat (normal) */
276 p_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
278 /* Base skill -- combat (shooting) */
279 p_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
281 /* Base skill -- combat (throwing) */
282 p_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
284 /* Base skill -- digging */
285 p_ptr->skill_dig = 0;
287 if (has_melee_weapon(INVEN_RARM)) p_ptr->migite = TRUE;
288 if (has_melee_weapon(INVEN_LARM))
290 p_ptr->hidarite = TRUE;
291 if (!p_ptr->migite) default_hand = 1;
294 if (CAN_TWO_HANDS_WIELDING())
296 if (p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
297 object_allow_two_hands_wielding(&inventory[INVEN_RARM]))
299 p_ptr->ryoute = TRUE;
301 else if (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
302 object_allow_two_hands_wielding(&inventory[INVEN_LARM]))
304 p_ptr->ryoute = TRUE;
308 switch (p_ptr->pclass)
311 case CLASS_FORCETRAINER:
312 case CLASS_BERSERKER:
313 if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
315 p_ptr->migite = TRUE;
316 p_ptr->ryoute = TRUE;
323 if (!p_ptr->migite && !p_ptr->hidarite)
325 if (empty_hands_status & EMPTY_HAND_RARM) p_ptr->migite = TRUE;
326 else if (empty_hands_status == EMPTY_HAND_LARM)
328 p_ptr->hidarite = TRUE;
333 if (p_ptr->special_defense & KAMAE_MASK)
335 if (!(empty_hands_status & EMPTY_HAND_RARM))
337 set_action(ACTION_NONE);
341 switch (p_ptr->pclass)
344 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
345 if (p_ptr->lev > 44) p_ptr->regenerate = TRUE;
348 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
350 case CLASS_CHAOS_WARRIOR:
351 if (p_ptr->lev > 29) p_ptr->resist_chaos = TRUE;
352 if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
354 case CLASS_MINDCRAFTER:
355 if (p_ptr->lev > 9) p_ptr->resist_fear = TRUE;
356 if (p_ptr->lev > 19) p_ptr->sustain_wis = TRUE;
357 if (p_ptr->lev > 29) p_ptr->resist_conf = TRUE;
358 if (p_ptr->lev > 39) p_ptr->telepathy = TRUE;
361 case CLASS_FORCETRAINER:
362 /* Unencumbered Monks become faster every 10 levels */
363 if (!(heavy_armor()))
365 if (!(prace_is_(RACE_KLACKON) ||
366 prace_is_(RACE_SPRITE) ||
367 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
368 new_speed += (p_ptr->lev) / 10;
370 /* Free action if unencumbered at level 25 */
372 p_ptr->free_act = TRUE;
377 p_ptr->dis_to_a -= 50;
380 p_ptr->resist_sound = TRUE;
383 if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
385 case CLASS_BERSERKER:
387 p_ptr->sustain_str = TRUE;
388 p_ptr->sustain_dex = TRUE;
389 p_ptr->sustain_con = TRUE;
390 p_ptr->regenerate = TRUE;
391 p_ptr->free_act = TRUE;
393 if (p_ptr->lev > 29) new_speed++;
394 if (p_ptr->lev > 39) new_speed++;
395 if (p_ptr->lev > 44) new_speed++;
396 if (p_ptr->lev > 49) new_speed++;
397 p_ptr->to_a += 10 + p_ptr->lev / 2;
398 p_ptr->dis_to_a += 10 + p_ptr->lev / 2;
399 p_ptr->skill_dig += (100 + p_ptr->lev * 8);
400 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
401 p_ptr->redraw |= PR_STATUS;
403 case CLASS_MIRROR_MASTER:
404 if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
407 /* Unencumbered Ninjas become faster every 10 levels */
410 new_speed -= (p_ptr->lev) / 10;
411 p_ptr->skill_stl -= (p_ptr->lev) / 10;
413 else if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
414 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
417 if (!(prace_is_(RACE_KLACKON) ||
418 prace_is_(RACE_SPRITE) ||
419 (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
420 new_speed += (p_ptr->lev) / 10;
421 p_ptr->skill_stl += (p_ptr->lev) / 10;
423 /* Free action if unencumbered at level 25 */
425 p_ptr->free_act = TRUE;
427 if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
428 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
430 p_ptr->to_a += p_ptr->lev / 2 + 5;
431 p_ptr->dis_to_a += p_ptr->lev / 2 + 5;
433 p_ptr->slow_digest = TRUE;
434 p_ptr->resist_fear = TRUE;
435 if (p_ptr->lev > 19) p_ptr->resist_pois = TRUE;
436 if (p_ptr->lev > 24) p_ptr->sustain_dex = TRUE;
437 if (p_ptr->lev > 29) p_ptr->see_inv = TRUE;
440 p_ptr->oppose_pois = 1;
441 p_ptr->redraw |= PR_STATUS;
443 p_ptr->see_nocto = TRUE;
448 if (p_ptr->mimic_form)
450 switch (p_ptr->mimic_form)
453 p_ptr->hold_exp = TRUE;
454 p_ptr->resist_chaos = TRUE;
455 p_ptr->resist_neth = TRUE;
456 p_ptr->resist_fire = TRUE;
457 p_ptr->oppose_fire = 1;
458 p_ptr->see_inv = TRUE;
460 p_ptr->redraw |= PR_STATUS;
462 p_ptr->dis_to_a += 10;
465 case MIMIC_DEMON_LORD:
466 p_ptr->hold_exp = TRUE;
467 p_ptr->resist_chaos = TRUE;
468 p_ptr->resist_neth = TRUE;
469 p_ptr->immune_fire = TRUE;
470 p_ptr->resist_acid = TRUE;
471 p_ptr->resist_fire = TRUE;
472 p_ptr->resist_cold = TRUE;
473 p_ptr->resist_elec = TRUE;
474 p_ptr->resist_pois = TRUE;
475 p_ptr->resist_conf = TRUE;
476 p_ptr->resist_disen = TRUE;
477 p_ptr->resist_nexus = TRUE;
478 p_ptr->resist_fear = TRUE;
479 p_ptr->sh_fire = TRUE;
480 p_ptr->see_inv = TRUE;
481 p_ptr->telepathy = TRUE;
482 p_ptr->levitation = TRUE;
483 p_ptr->kill_wall = TRUE;
486 p_ptr->dis_to_a += 20;
490 p_ptr->resist_dark = TRUE;
491 p_ptr->hold_exp = TRUE;
492 p_ptr->resist_neth = TRUE;
493 p_ptr->resist_cold = TRUE;
494 p_ptr->resist_pois = TRUE;
495 p_ptr->see_inv = TRUE;
498 p_ptr->dis_to_a += 10;
499 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
505 switch (p_ptr->prace)
508 p_ptr->resist_lite = TRUE;
511 p_ptr->hold_exp = TRUE;
514 p_ptr->free_act = TRUE;
517 p_ptr->resist_blind = TRUE;
520 p_ptr->resist_dark = TRUE;
522 case RACE_HALF_TROLL:
523 p_ptr->sustain_str = TRUE;
527 /* High level trolls heal fast... */
528 p_ptr->regenerate = TRUE;
530 if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_BERSERKER)
532 p_ptr->slow_digest = TRUE;
533 /* Let's not make Regeneration
534 * a disadvantage for the poor warriors who can
535 * never learn a spell that satisfies hunger (actually
536 * neither can rogues, but half-trolls are not
537 * supposed to play rogues) */
542 p_ptr->sustain_con = TRUE;
543 p_ptr->regenerate = TRUE; /* Amberites heal fast... */
546 p_ptr->resist_lite = TRUE;
547 p_ptr->see_inv = TRUE;
550 p_ptr->resist_fear = TRUE;
553 p_ptr->resist_dark = TRUE;
554 p_ptr->sustain_str = TRUE;
556 case RACE_HALF_GIANT:
557 p_ptr->sustain_str = TRUE;
558 p_ptr->resist_shard = TRUE;
560 case RACE_HALF_TITAN:
561 p_ptr->resist_chaos = TRUE;
564 p_ptr->resist_sound = TRUE;
567 p_ptr->resist_acid = TRUE;
568 if (p_ptr->lev > 19) p_ptr->immune_acid = TRUE;
571 p_ptr->resist_conf = TRUE;
572 p_ptr->resist_acid = TRUE;
574 /* Klackons become faster */
575 new_speed += (p_ptr->lev) / 10;
578 p_ptr->resist_pois = TRUE;
581 p_ptr->resist_disen = TRUE;
582 p_ptr->resist_dark = TRUE;
585 p_ptr->resist_dark = TRUE;
586 if (p_ptr->lev > 19) p_ptr->see_inv = TRUE;
589 p_ptr->levitation = TRUE;
590 if (p_ptr->lev > 4) p_ptr->resist_fire = TRUE;
591 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
592 if (p_ptr->lev > 14) p_ptr->resist_acid = TRUE;
593 if (p_ptr->lev > 19) p_ptr->resist_elec = TRUE;
594 if (p_ptr->lev > 34) p_ptr->resist_pois = TRUE;
596 case RACE_MIND_FLAYER:
597 p_ptr->sustain_int = TRUE;
598 p_ptr->sustain_wis = TRUE;
599 if (p_ptr->lev > 14) p_ptr->see_inv = TRUE;
600 if (p_ptr->lev > 29) p_ptr->telepathy = TRUE;
603 p_ptr->resist_fire = TRUE;
604 if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
607 p_ptr->slow_digest = TRUE;
608 p_ptr->free_act = TRUE;
609 p_ptr->see_inv = TRUE;
610 p_ptr->resist_pois = TRUE;
611 if (p_ptr->lev > 34) p_ptr->hold_exp = TRUE;
614 p_ptr->resist_shard = TRUE;
615 p_ptr->hold_exp = TRUE;
616 p_ptr->see_inv = TRUE;
617 p_ptr->resist_pois = TRUE;
618 if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
621 p_ptr->resist_neth = TRUE;
622 p_ptr->hold_exp = TRUE;
623 p_ptr->see_inv = TRUE;
624 p_ptr->resist_pois = TRUE;
625 p_ptr->slow_digest = TRUE;
626 if (p_ptr->lev > 4) p_ptr->resist_cold = TRUE;
629 p_ptr->resist_dark = TRUE;
630 p_ptr->hold_exp = TRUE;
631 p_ptr->resist_neth = TRUE;
632 p_ptr->resist_cold = TRUE;
633 p_ptr->resist_pois = TRUE;
634 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
637 p_ptr->levitation = TRUE;
638 p_ptr->free_act = TRUE;
639 p_ptr->resist_neth = TRUE;
640 p_ptr->hold_exp = TRUE;
641 p_ptr->see_inv = TRUE;
642 p_ptr->resist_pois = TRUE;
643 p_ptr->slow_digest = TRUE;
644 p_ptr->resist_cold = TRUE;
645 p_ptr->pass_wall = TRUE;
646 if (p_ptr->lev > 34) p_ptr->telepathy = TRUE;
649 p_ptr->levitation = TRUE;
650 p_ptr->resist_lite = TRUE;
652 /* Sprites become faster */
653 new_speed += (p_ptr->lev) / 10;
656 p_ptr->resist_conf = TRUE;
657 p_ptr->resist_sound = TRUE;
660 /* Ents dig like maniacs, but only with their hands. */
661 if (!inventory[INVEN_RARM].k_idx)
662 p_ptr->skill_dig += p_ptr->lev * 10;
663 /* Ents get tougher and stronger as they age, but lose dexterity. */
664 if (p_ptr->lev > 25) p_ptr->stat_add[A_STR]++;
665 if (p_ptr->lev > 40) p_ptr->stat_add[A_STR]++;
666 if (p_ptr->lev > 45) p_ptr->stat_add[A_STR]++;
668 if (p_ptr->lev > 25) p_ptr->stat_add[A_DEX]--;
669 if (p_ptr->lev > 40) p_ptr->stat_add[A_DEX]--;
670 if (p_ptr->lev > 45) p_ptr->stat_add[A_DEX]--;
672 if (p_ptr->lev > 25) p_ptr->stat_add[A_CON]++;
673 if (p_ptr->lev > 40) p_ptr->stat_add[A_CON]++;
674 if (p_ptr->lev > 45) p_ptr->stat_add[A_CON]++;
677 p_ptr->levitation = TRUE;
678 p_ptr->see_inv = TRUE;
682 p_ptr->resist_fire = TRUE;
683 p_ptr->resist_neth = TRUE;
684 p_ptr->hold_exp = TRUE;
685 if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
688 p_ptr->oppose_fire = 1;
689 p_ptr->redraw |= PR_STATUS;
694 p_ptr->sustain_con = TRUE;
697 p_ptr->levitation = TRUE;
700 p_ptr->resist_conf = TRUE;
703 p_ptr->slow_digest = TRUE;
704 p_ptr->free_act = TRUE;
705 p_ptr->resist_pois = TRUE;
706 p_ptr->hold_exp = TRUE;
709 p_ptr->resist_water = TRUE;
717 if (p_ptr->ult_res || (p_ptr->special_defense & KATA_MUSOU))
719 p_ptr->see_inv = TRUE;
720 p_ptr->free_act = TRUE;
721 p_ptr->slow_digest = TRUE;
722 p_ptr->regenerate = TRUE;
723 p_ptr->levitation = TRUE;
724 p_ptr->hold_exp = TRUE;
725 p_ptr->telepathy = TRUE;
727 p_ptr->sustain_str = TRUE;
728 p_ptr->sustain_int = TRUE;
729 p_ptr->sustain_wis = TRUE;
730 p_ptr->sustain_con = TRUE;
731 p_ptr->sustain_dex = TRUE;
732 p_ptr->sustain_chr = TRUE;
733 p_ptr->resist_acid = TRUE;
734 p_ptr->resist_elec = TRUE;
735 p_ptr->resist_fire = TRUE;
736 p_ptr->resist_cold = TRUE;
737 p_ptr->resist_pois = TRUE;
738 p_ptr->resist_conf = TRUE;
739 p_ptr->resist_sound = TRUE;
740 p_ptr->resist_lite = TRUE;
741 p_ptr->resist_dark = TRUE;
742 p_ptr->resist_chaos = TRUE;
743 p_ptr->resist_disen = TRUE;
744 p_ptr->resist_shard = TRUE;
745 p_ptr->resist_nexus = TRUE;
746 p_ptr->resist_blind = TRUE;
747 p_ptr->resist_neth = TRUE;
748 p_ptr->resist_fear = TRUE;
749 p_ptr->reflect = TRUE;
750 p_ptr->sh_fire = TRUE;
751 p_ptr->sh_elec = TRUE;
752 p_ptr->sh_cold = TRUE;
754 p_ptr->dis_to_a += 100;
756 /* Temporary shield */
757 else if (p_ptr->tsubureru || p_ptr->shield || p_ptr->magicdef)
760 p_ptr->dis_to_a += 50;
763 if (p_ptr->tim_res_nether)
765 p_ptr->resist_neth = TRUE;
767 if (p_ptr->tim_sh_fire)
769 p_ptr->sh_fire = TRUE;
771 if (p_ptr->tim_res_time)
773 p_ptr->resist_time = TRUE;
777 if (p_ptr->pseikaku == SEIKAKU_SEXY) p_ptr->cursed |= (TRC_AGGRAVATE);
779 if (p_ptr->pseikaku == SEIKAKU_NAMAKE) p_ptr->to_m_chance += 10;
780 if (p_ptr->pseikaku == SEIKAKU_KIREMONO) p_ptr->to_m_chance -= 3;
781 if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) p_ptr->to_m_chance++;
783 if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
785 p_ptr->to_m_chance += 5;
786 p_ptr->resist_conf = TRUE;
790 if (p_ptr->pseikaku == SEIKAKU_LUCKY) p_ptr->muta3 |= MUT3_GOOD_LUCK;
792 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
794 p_ptr->resist_blind = TRUE;
795 p_ptr->resist_conf = TRUE;
796 p_ptr->hold_exp = TRUE;
797 if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
799 if ((p_ptr->prace != RACE_KLACKON) && (p_ptr->prace != RACE_SPRITE))
800 /* Munchkin become faster */
801 new_speed += (p_ptr->lev) / 10 + 5;
804 if (music_singing(MUSIC_WALL))
806 p_ptr->kill_wall = TRUE;
809 /* Hack -- apply racial/class stat maxes */
810 /* Apply the racial modifiers */
811 for (i = 0; i < A_MAX; i++)
813 /* Modify the stats for "race" */
814 p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
818 /* I'm adding the mutations here for the lack of a better place... */
822 if (p_ptr->muta3 & MUT3_HYPER_STR)
824 p_ptr->stat_add[A_STR] += 4;
828 if (p_ptr->muta3 & MUT3_PUNY)
830 p_ptr->stat_add[A_STR] -= 4;
833 /* Living computer */
834 if (p_ptr->muta3 & MUT3_HYPER_INT)
836 p_ptr->stat_add[A_INT] += 4;
837 p_ptr->stat_add[A_WIS] += 4;
841 if (p_ptr->muta3 & MUT3_MORONIC)
843 p_ptr->stat_add[A_INT] -= 4;
844 p_ptr->stat_add[A_WIS] -= 4;
847 if (p_ptr->muta3 & MUT3_RESILIENT)
849 p_ptr->stat_add[A_CON] += 4;
852 if (p_ptr->muta3 & MUT3_XTRA_FAT)
854 p_ptr->stat_add[A_CON] += 2;
858 if (p_ptr->muta3 & MUT3_ALBINO)
860 p_ptr->stat_add[A_CON] -= 4;
863 if (p_ptr->muta3 & MUT3_FLESH_ROT)
865 p_ptr->stat_add[A_CON] -= 2;
866 p_ptr->stat_add[A_CHR] -= 1;
867 p_ptr->regenerate = FALSE;
868 /* Cancel innate regeneration */
871 if (p_ptr->muta3 & MUT3_SILLY_VOI)
873 p_ptr->stat_add[A_CHR] -= 4;
876 if (p_ptr->muta3 & MUT3_BLANK_FAC)
878 p_ptr->stat_add[A_CHR] -= 1;
881 if (p_ptr->muta3 & MUT3_XTRA_EYES)
883 p_ptr->skill_fos += 15;
884 p_ptr->skill_srh += 15;
887 if (p_ptr->muta3 & MUT3_MAGIC_RES)
889 p_ptr->skill_sav += (15 + (p_ptr->lev / 5));
892 if (p_ptr->muta3 & MUT3_XTRA_NOIS)
894 p_ptr->skill_stl -= 3;
897 if (p_ptr->muta3 & MUT3_INFRAVIS)
899 p_ptr->see_infra += 3;
902 if (p_ptr->muta3 & MUT3_XTRA_LEGS)
907 if (p_ptr->muta3 & MUT3_SHORT_LEG)
912 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
914 p_ptr->sh_elec = TRUE;
917 if (p_ptr->muta3 & MUT3_FIRE_BODY)
919 p_ptr->sh_fire = TRUE;
923 if (p_ptr->muta3 & MUT3_WART_SKIN)
925 p_ptr->stat_add[A_CHR] -= 2;
927 p_ptr->dis_to_a += 5;
930 if (p_ptr->muta3 & MUT3_SCALES)
932 p_ptr->stat_add[A_CHR] -= 1;
934 p_ptr->dis_to_a += 10;
937 if (p_ptr->muta3 & MUT3_IRON_SKIN)
939 p_ptr->stat_add[A_DEX] -= 1;
941 p_ptr->dis_to_a += 25;
944 if (p_ptr->muta3 & MUT3_WINGS)
946 p_ptr->levitation = TRUE;
949 if (p_ptr->muta3 & MUT3_FEARLESS)
951 p_ptr->resist_fear = TRUE;
954 if (p_ptr->muta3 & MUT3_REGEN)
956 p_ptr->regenerate = TRUE;
959 if (p_ptr->muta3 & MUT3_ESP)
961 p_ptr->telepathy = TRUE;
964 if (p_ptr->muta3 & MUT3_LIMBER)
966 p_ptr->stat_add[A_DEX] += 3;
969 if (p_ptr->muta3 & MUT3_ARTHRITIS)
971 p_ptr->stat_add[A_DEX] -= 3;
974 if (p_ptr->muta3 & MUT3_MOTION)
976 p_ptr->free_act = TRUE;
977 p_ptr->skill_stl += 1;
980 if (p_ptr->muta3 & MUT3_ILL_NORM)
982 p_ptr->stat_add[A_CHR] = 0;
988 p_ptr->stat_add[A_STR] += 4;
989 p_ptr->stat_add[A_CON] += 4;
992 /* Scan the usable inventory */
993 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
995 int bonus_to_h, bonus_to_d;
996 o_ptr = &inventory[i];
998 /* Skip non-objects */
999 if (!o_ptr->k_idx) continue;
1001 /* Extract the item flags */
1002 object_flags(o_ptr, flgs);
1004 p_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
1005 if (o_ptr->name1 == ART_CHAINSWORD) p_ptr->cursed |= TRC_CHAINSWORD;
1008 if (have_flag(flgs, TR_STR)) p_ptr->stat_add[A_STR] += o_ptr->pval;
1009 if (have_flag(flgs, TR_INT)) p_ptr->stat_add[A_INT] += o_ptr->pval;
1010 if (have_flag(flgs, TR_WIS)) p_ptr->stat_add[A_WIS] += o_ptr->pval;
1011 if (have_flag(flgs, TR_DEX)) p_ptr->stat_add[A_DEX] += o_ptr->pval;
1012 if (have_flag(flgs, TR_CON)) p_ptr->stat_add[A_CON] += o_ptr->pval;
1013 if (have_flag(flgs, TR_CHR)) p_ptr->stat_add[A_CHR] += o_ptr->pval;
1015 if (have_flag(flgs, TR_MAGIC_MASTERY)) p_ptr->skill_dev += 8 * o_ptr->pval;
1017 /* Affect stealth */
1018 if (have_flag(flgs, TR_STEALTH)) p_ptr->skill_stl += o_ptr->pval;
1020 /* Affect searching ability (factor of five) */
1021 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_srh += (o_ptr->pval * 5);
1023 /* Affect searching frequency (factor of five) */
1024 if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_fos += (o_ptr->pval * 5);
1026 /* Affect infravision */
1027 if (have_flag(flgs, TR_INFRA)) p_ptr->see_infra += o_ptr->pval;
1029 /* Affect digging (factor of 20) */
1030 if (have_flag(flgs, TR_TUNNEL)) p_ptr->skill_dig += (o_ptr->pval * 20);
1033 if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
1036 if (have_flag(flgs, TR_BLOWS))
1038 if ((i == INVEN_RARM || i == INVEN_RIGHT) && !p_ptr->ryoute) extra_blows[0] += o_ptr->pval;
1039 else if ((i == INVEN_LARM || i == INVEN_LEFT) && !p_ptr->ryoute) extra_blows[1] += o_ptr->pval;
1040 else { extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval; }
1043 /* Hack -- cause earthquakes */
1044 if (have_flag(flgs, TR_IMPACT)) p_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
1047 if (have_flag(flgs, TR_AGGRAVATE)) p_ptr->cursed |= TRC_AGGRAVATE;
1048 if (have_flag(flgs, TR_DRAIN_EXP)) p_ptr->cursed |= TRC_DRAIN_EXP;
1049 if (have_flag(flgs, TR_TY_CURSE)) p_ptr->cursed |= TRC_TY_CURSE;
1050 if (have_flag(flgs, TR_ADD_L_CURSE)) p_ptr->cursed |= TRC_ADD_L_CURSE;
1051 if (have_flag(flgs, TR_ADD_H_CURSE)) p_ptr->cursed |= TRC_ADD_H_CURSE;
1052 if (have_flag(flgs, TR_DRAIN_HP)) p_ptr->cursed |= TRC_DRAIN_HP;
1053 if (have_flag(flgs, TR_DRAIN_MANA)) p_ptr->cursed |= TRC_DRAIN_MANA;
1054 if (have_flag(flgs, TR_CALL_ANIMAL)) p_ptr->cursed |= TRC_CALL_ANIMAL;
1055 if (have_flag(flgs, TR_CALL_DEMON)) p_ptr->cursed |= TRC_CALL_DEMON;
1056 if (have_flag(flgs, TR_CALL_DRAGON)) p_ptr->cursed |= TRC_CALL_DRAGON;
1057 if (have_flag(flgs, TR_CALL_UNDEAD)) p_ptr->cursed |= TRC_CALL_UNDEAD;
1058 if (have_flag(flgs, TR_COWARDICE)) p_ptr->cursed |= TRC_COWARDICE;
1059 if (have_flag(flgs, TR_LOW_MELEE)) p_ptr->cursed |= TRC_LOW_MELEE;
1060 if (have_flag(flgs, TR_LOW_AC)) p_ptr->cursed |= TRC_LOW_AC;
1061 if (have_flag(flgs, TR_LOW_MAGIC)) p_ptr->cursed |= TRC_LOW_MAGIC;
1062 if (have_flag(flgs, TR_FAST_DIGEST)) p_ptr->cursed |= TRC_FAST_DIGEST;
1063 if (have_flag(flgs, TR_SLOW_REGEN)) p_ptr->cursed |= TRC_SLOW_REGEN;
1064 if (have_flag(flgs, TR_DEC_MANA)) p_ptr->dec_mana = TRUE;
1065 if (have_flag(flgs, TR_BLESSED)) p_ptr->bless_blade = TRUE;
1066 if (have_flag(flgs, TR_XTRA_MIGHT)) p_ptr->xtra_might = TRUE;
1067 if (have_flag(flgs, TR_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
1068 if (have_flag(flgs, TR_REGEN)) p_ptr->regenerate = TRUE;
1069 if (have_flag(flgs, TR_TELEPATHY)) p_ptr->telepathy = TRUE;
1070 if (have_flag(flgs, TR_ESP_ANIMAL)) p_ptr->esp_animal = TRUE;
1071 if (have_flag(flgs, TR_ESP_UNDEAD)) p_ptr->esp_undead = TRUE;
1072 if (have_flag(flgs, TR_ESP_DEMON)) p_ptr->esp_demon = TRUE;
1073 if (have_flag(flgs, TR_ESP_ORC)) p_ptr->esp_orc = TRUE;
1074 if (have_flag(flgs, TR_ESP_TROLL)) p_ptr->esp_troll = TRUE;
1075 if (have_flag(flgs, TR_ESP_GIANT)) p_ptr->esp_giant = TRUE;
1076 if (have_flag(flgs, TR_ESP_DRAGON)) p_ptr->esp_dragon = TRUE;
1077 if (have_flag(flgs, TR_ESP_HUMAN)) p_ptr->esp_human = TRUE;
1078 if (have_flag(flgs, TR_ESP_EVIL)) p_ptr->esp_evil = TRUE;
1079 if (have_flag(flgs, TR_ESP_GOOD)) p_ptr->esp_good = TRUE;
1080 if (have_flag(flgs, TR_ESP_NONLIVING)) p_ptr->esp_nonliving = TRUE;
1081 if (have_flag(flgs, TR_ESP_UNIQUE)) p_ptr->esp_unique = TRUE;
1083 if (have_flag(flgs, TR_SEE_INVIS)) p_ptr->see_inv = TRUE;
1084 if (have_flag(flgs, TR_LEVITATION)) p_ptr->levitation = TRUE;
1085 if (have_flag(flgs, TR_FREE_ACT)) p_ptr->free_act = TRUE;
1086 if (have_flag(flgs, TR_HOLD_EXP)) p_ptr->hold_exp = TRUE;
1087 if (have_flag(flgs, TR_WARNING)) {
1088 if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription), '$')))
1089 p_ptr->warning = TRUE;
1092 if (have_flag(flgs, TR_TELEPORT))
1094 if (object_is_cursed(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
1097 concptr insc = quark_str(o_ptr->inscription);
1099 if (o_ptr->inscription && my_strchr(insc, '.'))
1102 * {.} will stop random teleportation.
1107 /* Controlled random teleportation */
1108 p_ptr->cursed |= TRC_TELEPORT_SELF;
1113 /* Immunity flags */
1114 if (have_flag(flgs, TR_IM_FIRE)) p_ptr->immune_fire = TRUE;
1115 if (have_flag(flgs, TR_IM_ACID)) p_ptr->immune_acid = TRUE;
1116 if (have_flag(flgs, TR_IM_COLD)) p_ptr->immune_cold = TRUE;
1117 if (have_flag(flgs, TR_IM_ELEC)) p_ptr->immune_elec = TRUE;
1119 /* Resistance flags */
1120 if (have_flag(flgs, TR_RES_ACID)) p_ptr->resist_acid = TRUE;
1121 if (have_flag(flgs, TR_RES_ELEC)) p_ptr->resist_elec = TRUE;
1122 if (have_flag(flgs, TR_RES_FIRE)) p_ptr->resist_fire = TRUE;
1123 if (have_flag(flgs, TR_RES_COLD)) p_ptr->resist_cold = TRUE;
1124 if (have_flag(flgs, TR_RES_POIS)) p_ptr->resist_pois = TRUE;
1125 if (have_flag(flgs, TR_RES_FEAR)) p_ptr->resist_fear = TRUE;
1126 if (have_flag(flgs, TR_RES_CONF)) p_ptr->resist_conf = TRUE;
1127 if (have_flag(flgs, TR_RES_SOUND)) p_ptr->resist_sound = TRUE;
1128 if (have_flag(flgs, TR_RES_LITE)) p_ptr->resist_lite = TRUE;
1129 if (have_flag(flgs, TR_RES_DARK)) p_ptr->resist_dark = TRUE;
1130 if (have_flag(flgs, TR_RES_CHAOS)) p_ptr->resist_chaos = TRUE;
1131 if (have_flag(flgs, TR_RES_DISEN)) p_ptr->resist_disen = TRUE;
1132 if (have_flag(flgs, TR_RES_SHARDS)) p_ptr->resist_shard = TRUE;
1133 if (have_flag(flgs, TR_RES_NEXUS)) p_ptr->resist_nexus = TRUE;
1134 if (have_flag(flgs, TR_RES_BLIND)) p_ptr->resist_blind = TRUE;
1135 if (have_flag(flgs, TR_RES_NETHER)) p_ptr->resist_neth = TRUE;
1137 if (have_flag(flgs, TR_REFLECT)) p_ptr->reflect = TRUE;
1138 if (have_flag(flgs, TR_SH_FIRE)) p_ptr->sh_fire = TRUE;
1139 if (have_flag(flgs, TR_SH_ELEC)) p_ptr->sh_elec = TRUE;
1140 if (have_flag(flgs, TR_SH_COLD)) p_ptr->sh_cold = TRUE;
1141 if (have_flag(flgs, TR_NO_MAGIC)) p_ptr->anti_magic = TRUE;
1142 if (have_flag(flgs, TR_NO_TELE)) p_ptr->anti_tele = TRUE;
1145 if (have_flag(flgs, TR_SUST_STR)) p_ptr->sustain_str = TRUE;
1146 if (have_flag(flgs, TR_SUST_INT)) p_ptr->sustain_int = TRUE;
1147 if (have_flag(flgs, TR_SUST_WIS)) p_ptr->sustain_wis = TRUE;
1148 if (have_flag(flgs, TR_SUST_DEX)) p_ptr->sustain_dex = TRUE;
1149 if (have_flag(flgs, TR_SUST_CON)) p_ptr->sustain_con = TRUE;
1150 if (have_flag(flgs, TR_SUST_CHR)) p_ptr->sustain_chr = TRUE;
1152 if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
1153 if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
1154 if (o_ptr->name2 == EGO_RING_RES_TIME) p_ptr->resist_time = TRUE;
1155 if (o_ptr->name2 == EGO_RING_THROW) p_ptr->mighty_throw = TRUE;
1156 if (have_flag(flgs, TR_EASY_SPELL)) p_ptr->easy_spell = TRUE;
1157 if (o_ptr->name2 == EGO_AMU_FOOL) p_ptr->heavy_spell = TRUE;
1158 if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
1160 if (o_ptr->curse_flags & TRC_LOW_MAGIC)
1162 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1164 p_ptr->to_m_chance += 10;
1168 p_ptr->to_m_chance += 3;
1172 if (o_ptr->tval == TV_CAPTURE) continue;
1174 /* Modify the base armor class */
1175 p_ptr->ac += o_ptr->ac;
1177 /* The base armor class is always known */
1178 p_ptr->dis_ac += o_ptr->ac;
1180 /* Apply the bonuses to armor class */
1181 p_ptr->to_a += o_ptr->to_a;
1183 /* Apply the mental bonuses to armor class, if known */
1184 if (object_is_known(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
1186 if (o_ptr->curse_flags & TRC_LOW_MELEE)
1188 int slot = i - INVEN_RARM;
1191 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1193 p_ptr->to_h[slot] -= 15;
1194 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 15;
1198 p_ptr->to_h[slot] -= 5;
1199 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 5;
1204 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1206 p_ptr->to_h_b -= 15;
1207 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 15;
1212 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 5;
1217 if (o_ptr->curse_flags & TRC_LOW_AC)
1219 if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1222 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 30;
1227 if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 10;
1231 /* Hack -- do not apply "weapon" bonuses */
1232 if (i == INVEN_RARM && has_melee_weapon(i)) continue;
1233 if (i == INVEN_LARM && has_melee_weapon(i)) continue;
1235 /* Hack -- do not apply "bow" bonuses */
1236 if (i == INVEN_BOW) continue;
1238 bonus_to_h = o_ptr->to_h;
1239 bonus_to_d = o_ptr->to_d;
1241 if (p_ptr->pclass == CLASS_NINJA)
1243 if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h + 1) / 2;
1244 if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d + 1) / 2;
1247 /* To Bow and Natural attack */
1249 /* Apply the bonuses to hit/damage */
1250 p_ptr->to_h_b += (s16b)bonus_to_h;
1251 p_ptr->to_h_m += (s16b)bonus_to_h;
1252 p_ptr->to_d_m += (s16b)bonus_to_d;
1254 /* Apply the mental bonuses tp hit/damage, if known */
1255 if (object_is_known(o_ptr)) p_ptr->dis_to_h_b += (s16b)bonus_to_h;
1258 if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
1260 /* Apply the bonuses to hit/damage */
1261 p_ptr->to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
1262 p_ptr->to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
1264 /* Apply the mental bonuses tp hit/damage, if known */
1265 if (object_is_known(o_ptr))
1267 p_ptr->dis_to_h[i - INVEN_RIGHT] += (s16b)bonus_to_h;
1268 p_ptr->dis_to_d[i - INVEN_RIGHT] += (s16b)bonus_to_d;
1271 else if (p_ptr->migite && p_ptr->hidarite)
1273 /* Apply the bonuses to hit/damage */
1274 p_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
1275 p_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
1276 p_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
1277 p_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
1279 /* Apply the mental bonuses tp hit/damage, if known */
1280 if (object_is_known(o_ptr))
1282 p_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h + 1) / 2 : bonus_to_h;
1283 p_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h / 2 : bonus_to_h;
1284 p_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
1285 p_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
1290 /* Apply the bonuses to hit/damage */
1291 p_ptr->to_h[default_hand] += (s16b)bonus_to_h;
1292 p_ptr->to_d[default_hand] += (s16b)bonus_to_d;
1294 /* Apply the mental bonuses to hit/damage, if known */
1295 if (object_is_known(o_ptr))
1297 p_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
1298 p_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
1303 /* Shield skill bonus */
1304 if (object_is_armour(&inventory[INVEN_RARM]) || object_is_armour(&inventory[INVEN_LARM]))
1306 p_ptr->ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
1307 p_ptr->dis_ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
1310 if (old_mighty_throw != p_ptr->mighty_throw)
1312 /* Redraw average damege display of Shuriken */
1313 p_ptr->window |= PW_INVEN;
1316 if (p_ptr->cursed & TRC_TELEPORT) p_ptr->cursed &= ~(TRC_TELEPORT_SELF);
1318 /* Monks get extra ac for armour _not worn_ */
1319 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor())
1321 if (!(inventory[INVEN_BODY].k_idx))
1323 p_ptr->to_a += (p_ptr->lev * 3) / 2;
1324 p_ptr->dis_to_a += (p_ptr->lev * 3) / 2;
1326 if (!(inventory[INVEN_OUTER].k_idx) && (p_ptr->lev > 15))
1328 p_ptr->to_a += ((p_ptr->lev - 13) / 3);
1329 p_ptr->dis_to_a += ((p_ptr->lev - 13) / 3);
1331 if (!(inventory[INVEN_LARM].k_idx) && (p_ptr->lev > 10))
1333 p_ptr->to_a += ((p_ptr->lev - 8) / 3);
1334 p_ptr->dis_to_a += ((p_ptr->lev - 8) / 3);
1336 if (!(inventory[INVEN_HEAD].k_idx) && (p_ptr->lev > 4))
1338 p_ptr->to_a += (p_ptr->lev - 2) / 3;
1339 p_ptr->dis_to_a += (p_ptr->lev - 2) / 3;
1341 if (!(inventory[INVEN_HANDS].k_idx))
1343 p_ptr->to_a += (p_ptr->lev / 2);
1344 p_ptr->dis_to_a += (p_ptr->lev / 2);
1346 if (!(inventory[INVEN_FEET].k_idx))
1348 p_ptr->to_a += (p_ptr->lev / 3);
1349 p_ptr->dis_to_a += (p_ptr->lev / 3);
1351 if (p_ptr->special_defense & KAMAE_BYAKKO)
1353 p_ptr->stat_add[A_STR] += 2;
1354 p_ptr->stat_add[A_DEX] += 2;
1355 p_ptr->stat_add[A_CON] -= 3;
1357 else if (p_ptr->special_defense & KAMAE_SEIRYU)
1360 else if (p_ptr->special_defense & KAMAE_GENBU)
1362 p_ptr->stat_add[A_INT] -= 1;
1363 p_ptr->stat_add[A_WIS] -= 1;
1364 p_ptr->stat_add[A_DEX] -= 2;
1365 p_ptr->stat_add[A_CON] += 3;
1367 else if (p_ptr->special_defense & KAMAE_SUZAKU)
1369 p_ptr->stat_add[A_STR] -= 2;
1370 p_ptr->stat_add[A_INT] += 1;
1371 p_ptr->stat_add[A_WIS] += 1;
1372 p_ptr->stat_add[A_DEX] += 2;
1373 p_ptr->stat_add[A_CON] -= 2;
1377 if (p_ptr->special_defense & KATA_KOUKIJIN)
1379 for (i = 0; i < A_MAX; i++)
1380 p_ptr->stat_add[i] += 5;
1382 p_ptr->dis_to_a -= 50;
1385 /* Hack -- aura of fire also provides light */
1386 if (p_ptr->sh_fire) p_ptr->lite = TRUE;
1388 /* Golems also get an intrinsic AC bonus */
1389 if (prace_is_(RACE_GOLEM) || prace_is_(RACE_ANDROID))
1391 p_ptr->to_a += 10 + (p_ptr->lev * 2 / 5);
1392 p_ptr->dis_to_a += 10 + (p_ptr->lev * 2 / 5);
1396 if (p_ptr->realm1 == REALM_HEX)
1398 if (hex_spelling_any()) p_ptr->skill_stl -= (1 + CASTING_HEX_NUM(p_ptr));
1399 if (hex_spelling(HEX_DETECT_EVIL)) p_ptr->esp_evil = TRUE;
1400 if (hex_spelling(HEX_XTRA_MIGHT)) p_ptr->stat_add[A_STR] += 4;
1401 if (hex_spelling(HEX_BUILDING))
1403 p_ptr->stat_add[A_STR] += 4;
1404 p_ptr->stat_add[A_DEX] += 4;
1405 p_ptr->stat_add[A_CON] += 4;
1407 if (hex_spelling(HEX_DEMON_AURA))
1409 p_ptr->sh_fire = TRUE;
1410 p_ptr->regenerate = TRUE;
1412 if (hex_spelling(HEX_ICE_ARMOR))
1414 p_ptr->sh_cold = TRUE;
1416 p_ptr->dis_to_a += 30;
1418 if (hex_spelling(HEX_SHOCK_CLOAK))
1420 p_ptr->sh_elec = TRUE;
1423 for (i = INVEN_RARM; i <= INVEN_FEET; i++)
1425 ARMOUR_CLASS ac = 0;
1426 o_ptr = &inventory[i];
1427 if (!o_ptr->k_idx) continue;
1428 if (!object_is_armour(o_ptr)) continue;
1429 if (!object_is_cursed(o_ptr)) continue;
1431 if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
1432 if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
1433 p_ptr->to_a += (s16b)ac;
1434 p_ptr->dis_to_a += (s16b)ac;
1438 /* Calculate stats */
1439 for (i = 0; i < A_MAX; i++)
1443 /* Extract the new "stat_use" value for the stat */
1444 top = modify_stat_value(p_ptr->stat_max[i], p_ptr->stat_add[i]);
1446 /* Notice changes */
1447 if (p_ptr->stat_top[i] != top)
1449 /* Save the new value */
1450 p_ptr->stat_top[i] = (s16b)top;
1451 p_ptr->redraw |= (PR_STATS);
1452 p_ptr->window |= (PW_PLAYER);
1456 /* Extract the new "stat_use" value for the stat */
1457 use = modify_stat_value(p_ptr->stat_cur[i], p_ptr->stat_add[i]);
1459 if ((i == A_CHR) && (p_ptr->muta3 & MUT3_ILL_NORM))
1461 /* 10 to 18/90 charisma, guaranteed, based on level */
1462 if (use < 8 + 2 * p_ptr->lev)
1464 use = 8 + 2 * p_ptr->lev;
1468 /* Notice changes */
1469 if (p_ptr->stat_use[i] != use)
1471 /* Save the new value */
1472 p_ptr->stat_use[i] = (s16b)use;
1473 p_ptr->redraw |= (PR_STATS);
1474 p_ptr->window |= (PW_PLAYER);
1478 /* Values: 3, 4, ..., 17 */
1479 if (use <= 18) ind = (use - 3);
1481 /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
1482 else if (use <= 18 + 219) ind = (15 + (use - 18) / 10);
1484 /* Range: 18/220+ */
1487 /* Notice changes */
1488 if (p_ptr->stat_ind[i] != ind)
1490 /* Save the new index */
1491 p_ptr->stat_ind[i] = (s16b)ind;
1493 /* Change in CON affects Hitpoints */
1496 p_ptr->update |= (PU_HP);
1499 /* Change in INT may affect Mana/Spells */
1500 else if (i == A_INT)
1502 if (mp_ptr->spell_stat == A_INT)
1504 p_ptr->update |= (PU_MANA | PU_SPELLS);
1508 /* Change in WIS may affect Mana/Spells */
1509 else if (i == A_WIS)
1511 if (mp_ptr->spell_stat == A_WIS)
1513 p_ptr->update |= (PU_MANA | PU_SPELLS);
1517 /* Change in WIS may affect Mana/Spells */
1518 else if (i == A_CHR)
1520 if (mp_ptr->spell_stat == A_CHR)
1522 p_ptr->update |= (PU_MANA | PU_SPELLS);
1526 p_ptr->window |= (PW_PLAYER);
1531 /* Apply temporary "stun" */
1532 if (p_ptr->stun > 50)
1534 p_ptr->to_h[0] -= 20;
1535 p_ptr->to_h[1] -= 20;
1536 p_ptr->to_h_b -= 20;
1537 p_ptr->to_h_m -= 20;
1538 p_ptr->dis_to_h[0] -= 20;
1539 p_ptr->dis_to_h[1] -= 20;
1540 p_ptr->dis_to_h_b -= 20;
1541 p_ptr->to_d[0] -= 20;
1542 p_ptr->to_d[1] -= 20;
1543 p_ptr->to_d_m -= 20;
1544 p_ptr->dis_to_d[0] -= 20;
1545 p_ptr->dis_to_d[1] -= 20;
1547 else if (p_ptr->stun)
1549 p_ptr->to_h[0] -= 5;
1550 p_ptr->to_h[1] -= 5;
1553 p_ptr->dis_to_h[0] -= 5;
1554 p_ptr->dis_to_h[1] -= 5;
1555 p_ptr->dis_to_h_b -= 5;
1556 p_ptr->to_d[0] -= 5;
1557 p_ptr->to_d[1] -= 5;
1559 p_ptr->dis_to_d[0] -= 5;
1560 p_ptr->dis_to_d[1] -= 5;
1564 if (p_ptr->wraith_form)
1566 p_ptr->reflect = TRUE;
1567 p_ptr->pass_wall = TRUE;
1570 if (p_ptr->kabenuke)
1572 p_ptr->pass_wall = TRUE;
1575 /* Temporary blessing */
1579 p_ptr->dis_to_a += 5;
1580 p_ptr->to_h[0] += 10;
1581 p_ptr->to_h[1] += 10;
1582 p_ptr->to_h_b += 10;
1583 p_ptr->to_h_m += 10;
1584 p_ptr->dis_to_h[0] += 10;
1585 p_ptr->dis_to_h[1] += 10;
1586 p_ptr->dis_to_h_b += 10;
1589 if (p_ptr->magicdef)
1591 p_ptr->resist_blind = TRUE;
1592 p_ptr->resist_conf = TRUE;
1593 p_ptr->reflect = TRUE;
1594 p_ptr->free_act = TRUE;
1595 p_ptr->levitation = TRUE;
1598 /* Temporary "Hero" */
1601 p_ptr->to_h[0] += 12;
1602 p_ptr->to_h[1] += 12;
1603 p_ptr->to_h_b += 12;
1604 p_ptr->to_h_m += 12;
1605 p_ptr->dis_to_h[0] += 12;
1606 p_ptr->dis_to_h[1] += 12;
1607 p_ptr->dis_to_h_b += 12;
1610 /* Temporary "Beserk" */
1613 p_ptr->to_h[0] += 12;
1614 p_ptr->to_h[1] += 12;
1615 p_ptr->to_h_b -= 12;
1616 p_ptr->to_h_m += 12;
1617 p_ptr->to_d[0] += 3 + (p_ptr->lev / 5);
1618 p_ptr->to_d[1] += 3 + (p_ptr->lev / 5);
1619 p_ptr->to_d_m += 3 + (p_ptr->lev / 5);
1620 p_ptr->dis_to_h[0] += 12;
1621 p_ptr->dis_to_h[1] += 12;
1622 p_ptr->dis_to_h_b -= 12;
1623 p_ptr->dis_to_d[0] += 3 + (p_ptr->lev / 5);
1624 p_ptr->dis_to_d[1] += 3 + (p_ptr->lev / 5);
1626 p_ptr->dis_to_a -= 10;
1627 p_ptr->skill_stl -= 7;
1628 p_ptr->skill_dev -= 20;
1629 p_ptr->skill_sav -= 30;
1630 p_ptr->skill_srh -= 15;
1631 p_ptr->skill_fos -= 15;
1632 p_ptr->skill_tht -= 20;
1633 p_ptr->skill_dig += 30;
1636 /* Temporary "fast" */
1642 /* Temporary "slow" */
1648 /* Temporary "telepathy" */
1651 p_ptr->telepathy = TRUE;
1654 if (p_ptr->ele_immune)
1656 if (p_ptr->special_defense & DEFENSE_ACID)
1657 p_ptr->immune_acid = TRUE;
1658 else if (p_ptr->special_defense & DEFENSE_ELEC)
1659 p_ptr->immune_elec = TRUE;
1660 else if (p_ptr->special_defense & DEFENSE_FIRE)
1661 p_ptr->immune_fire = TRUE;
1662 else if (p_ptr->special_defense & DEFENSE_COLD)
1663 p_ptr->immune_cold = TRUE;
1666 /* Temporary see invisible */
1667 if (p_ptr->tim_invis)
1669 p_ptr->see_inv = TRUE;
1672 /* Temporary infravision boost */
1673 if (p_ptr->tim_infra)
1675 p_ptr->see_infra += 3;
1678 /* Temporary regeneration boost */
1679 if (p_ptr->tim_regen)
1681 p_ptr->regenerate = TRUE;
1684 /* Temporary levitation */
1685 if (p_ptr->tim_levitation)
1687 p_ptr->levitation = TRUE;
1690 /* Temporary reflection */
1691 if (p_ptr->tim_reflect)
1693 p_ptr->reflect = TRUE;
1696 /* Hack -- Hero/Shero -> Res fear */
1697 if (IS_HERO() || p_ptr->shero)
1699 p_ptr->resist_fear = TRUE;
1703 /* Hack -- Telepathy Change */
1704 if (p_ptr->telepathy != old_telepathy)
1706 p_ptr->update |= (PU_MONSTERS);
1709 if ((p_ptr->esp_animal != old_esp_animal) ||
1710 (p_ptr->esp_undead != old_esp_undead) ||
1711 (p_ptr->esp_demon != old_esp_demon) ||
1712 (p_ptr->esp_orc != old_esp_orc) ||
1713 (p_ptr->esp_troll != old_esp_troll) ||
1714 (p_ptr->esp_giant != old_esp_giant) ||
1715 (p_ptr->esp_dragon != old_esp_dragon) ||
1716 (p_ptr->esp_human != old_esp_human) ||
1717 (p_ptr->esp_evil != old_esp_evil) ||
1718 (p_ptr->esp_good != old_esp_good) ||
1719 (p_ptr->esp_nonliving != old_esp_nonliving) ||
1720 (p_ptr->esp_unique != old_esp_unique))
1722 p_ptr->update |= (PU_MONSTERS);
1725 /* Hack -- See Invis Change */
1726 if (p_ptr->see_inv != old_see_inv)
1728 p_ptr->update |= (PU_MONSTERS);
1731 /* Bloating slows the player down (a little) */
1732 if (p_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
1734 if (p_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
1736 if ((p_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
1737 (p_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
1739 p_ptr->to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
1740 p_ptr->dis_to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
1743 if (has_melee_weapon(INVEN_RARM) && has_melee_weapon(INVEN_LARM))
1745 int penalty1, penalty2;
1746 penalty1 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_RARM].weight) / 8);
1747 penalty2 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_LARM].weight) / 8);
1748 if ((inventory[INVEN_RARM].name1 == ART_QUICKTHORN) && (inventory[INVEN_LARM].name1 == ART_TINYTHORN))
1750 penalty1 = penalty1 / 2 - 5;
1751 penalty2 = penalty2 / 2 - 5;
1754 p_ptr->dis_to_a += 10;
1758 if (penalty1 > 0) penalty1 /= 2;
1759 if (penalty2 > 0) penalty2 /= 2;
1761 else if ((inventory[INVEN_LARM].tval == TV_SWORD) && ((inventory[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (inventory[INVEN_LARM].sval == SV_WAKIZASHI)))
1763 penalty1 = MAX(0, penalty1 - 10);
1764 penalty2 = MAX(0, penalty2 - 10);
1766 if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
1768 penalty1 = MIN(0, penalty1);
1769 penalty2 = MIN(0, penalty2);
1771 p_ptr->dis_to_a += 10;
1775 if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
1777 if ((inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
1780 if (inventory[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
1781 if (inventory[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
1782 p_ptr->to_h[0] -= (s16b)penalty1;
1783 p_ptr->to_h[1] -= (s16b)penalty2;
1784 p_ptr->dis_to_h[0] -= (s16b)penalty1;
1785 p_ptr->dis_to_h[1] -= (s16b)penalty2;
1788 /* Extract the current weight (in tenth pounds) */
1789 j = p_ptr->total_weight;
1793 /* Extract the "weight limit" (in tenth pounds) */
1794 i = (int)weight_limit();
1798 monster_type *riding_m_ptr = &m_list[p_ptr->riding];
1799 monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
1800 SPEED speed = riding_m_ptr->mspeed;
1802 if (riding_m_ptr->mspeed > 110)
1804 new_speed = 110 + (s16b)((speed - 110) * (p_ptr->skill_exp[GINOU_RIDING] * 3 + p_ptr->lev * 160L - 10000L) / (22000L));
1805 if (new_speed < 110) new_speed = 110;
1811 new_speed += (p_ptr->skill_exp[GINOU_RIDING] + p_ptr->lev * 160L) / 3200;
1812 if (MON_FAST(riding_m_ptr)) new_speed += 10;
1813 if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
1814 riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
1815 if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
1817 if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) p_ptr->pass_wall = FALSE;
1818 if (riding_r_ptr->flags2 & RF2_KILL_WALL) p_ptr->kill_wall = TRUE;
1820 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;
1822 /* Extract the "weight limit" */
1823 i = 1500 + riding_r_ptr->level * 25;
1826 /* Apply "encumbrance" from weight */
1827 if (j > i) new_speed -= ((j - i) / (i / 5));
1829 /* Searching slows the player down */
1830 if (p_ptr->action == ACTION_SEARCH) new_speed -= 10;
1833 if (p_ptr->prace == RACE_MERFOLK)
1835 if (have_flag(f_ptr->flags, FF_WATER))
1837 new_speed += (2 + p_ptr->lev / 10);
1839 else if (!p_ptr->levitation)
1846 /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
1847 p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
1848 p_ptr->to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1849 p_ptr->to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1850 p_ptr->to_d_m += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1851 p_ptr->to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1852 p_ptr->to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1853 p_ptr->to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1854 p_ptr->to_h_m += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1855 p_ptr->to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1856 p_ptr->to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1857 p_ptr->to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1858 p_ptr->to_h_m += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1860 /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
1861 p_ptr->dis_to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
1862 p_ptr->dis_to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1863 p_ptr->dis_to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1864 p_ptr->dis_to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1865 p_ptr->dis_to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1866 p_ptr->dis_to_h_b += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
1867 p_ptr->dis_to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1868 p_ptr->dis_to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1869 p_ptr->dis_to_h_b += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
1872 /* Obtain the "hold" value */
1873 hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
1876 /* Examine the "current bow" */
1877 o_ptr = &inventory[INVEN_BOW];
1879 /* It is hard to carholdry a heavy bow */
1880 p_ptr->heavy_shoot = is_heavy_shoot(o_ptr);
1881 if (p_ptr->heavy_shoot)
1883 /* Hard to wield a heavy bow */
1884 p_ptr->to_h_b += 2 * (hold - o_ptr->weight / 10);
1885 p_ptr->dis_to_h_b += 2 * (hold - o_ptr->weight / 10);
1888 /* Compute "extra shots" if needed */
1891 p_ptr->tval_ammo = (byte_hack)bow_tval_ammo(o_ptr);
1893 /* Apply special flags */
1894 if (o_ptr->k_idx && !p_ptr->heavy_shoot)
1897 p_ptr->num_fire = calc_num_fire(o_ptr);
1899 /* Snipers love Cross bows */
1900 if ((p_ptr->pclass == CLASS_SNIPER) &&
1901 (p_ptr->tval_ammo == TV_BOLT))
1903 p_ptr->to_h_b += (10 + (p_ptr->lev / 5));
1904 p_ptr->dis_to_h_b += (10 + (p_ptr->lev / 5));
1909 if (p_ptr->ryoute) hold *= 2;
1911 for (i = 0; i < 2; i++)
1913 /* Examine the "main weapon" */
1914 o_ptr = &inventory[INVEN_RARM + i];
1916 object_flags(o_ptr, flgs);
1918 /* Assume not heavy */
1919 p_ptr->heavy_wield[i] = FALSE;
1920 p_ptr->icky_wield[i] = FALSE;
1921 p_ptr->riding_wield[i] = FALSE;
1923 if (!has_melee_weapon(INVEN_RARM + i))
1925 p_ptr->num_blow[i] = 1;
1928 /* It is hard to hold a heavy weapon */
1929 if (hold < o_ptr->weight / 10)
1931 /* Hard to wield a heavy weapon */
1932 p_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
1933 p_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
1936 p_ptr->heavy_wield[i] = TRUE;
1938 else if (p_ptr->ryoute && (hold < o_ptr->weight / 5)) omoi = TRUE;
1940 if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
1943 p_ptr->dis_to_a += 5;
1946 /* Normal weapons */
1947 if (o_ptr->k_idx && !p_ptr->heavy_wield[i])
1949 int str_index, dex_index;
1951 int num = 0, wgt = 0, mul = 0, div = 0;
1953 /* Analyze the class */
1954 switch (p_ptr->pclass)
1957 num = 6; wgt = 70; mul = 5; break;
1959 case CLASS_BERSERKER:
1960 num = 6; wgt = 70; mul = 7; break;
1963 case CLASS_HIGH_MAGE:
1964 case CLASS_BLUE_MAGE:
1965 num = 3; wgt = 100; mul = 2; break;
1968 case CLASS_MAGIC_EATER:
1969 case CLASS_MINDCRAFTER:
1970 num = 5; wgt = 100; mul = 3; break;
1973 num = 5; wgt = 40; mul = 3; break;
1976 num = 5; wgt = 70; mul = 4; break;
1980 num = 5; wgt = 70; mul = 4; break;
1983 num = 5; wgt = 150; mul = 5; break;
1985 case CLASS_WARRIOR_MAGE:
1986 case CLASS_RED_MAGE:
1987 num = 5; wgt = 70; mul = 3; break;
1989 case CLASS_CHAOS_WARRIOR:
1990 num = 5; wgt = 70; mul = 4; break;
1993 num = 5; wgt = 60; mul = 3; break;
1996 num = 4; wgt = 100; mul = 3; break;
1998 case CLASS_IMITATOR:
1999 num = 5; wgt = 70; mul = 4; break;
2001 case CLASS_BEASTMASTER:
2002 num = 5; wgt = 70; mul = 3; break;
2005 if ((p_ptr->riding) && (have_flag(flgs, TR_RIDING))) { num = 5; wgt = 70; mul = 4; }
2006 else { num = 5; wgt = 100; mul = 3; }
2009 case CLASS_SORCERER:
2010 num = 1; wgt = 1; mul = 1; break;
2015 num = 4; wgt = 70; mul = 2; break;
2017 case CLASS_FORCETRAINER:
2018 num = 4; wgt = 60; mul = 2; break;
2020 case CLASS_MIRROR_MASTER:
2021 num = 3; wgt = 100; mul = 3; break;
2024 num = 4; wgt = 20; mul = 1; break;
2027 /* Hex - extra mights gives +1 bonus to max blows */
2028 if (hex_spelling(HEX_XTRA_MIGHT) || hex_spelling(HEX_BUILDING)) { num++; wgt /= 2; mul += 2; }
2030 /* Enforce a minimum "weight" (tenth pounds) */
2031 div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
2033 /* Access the strength vs weight */
2034 str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * mul / div);
2036 if (p_ptr->ryoute && !omoi) str_index++;
2037 if (p_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index - 1);
2040 if (str_index > 11) str_index = 11;
2042 /* Index by dexterity */
2043 dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]);
2046 if (dex_index > 11) dex_index = 11;
2048 /* Use the blows table */
2049 p_ptr->num_blow[i] = blows_table[str_index][dex_index];
2052 if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = (s16b)num;
2054 /* Add in the "bonus blows" */
2055 p_ptr->num_blow[i] += (s16b)extra_blows[i];
2058 if (p_ptr->pclass == CLASS_WARRIOR) p_ptr->num_blow[i] += (p_ptr->lev / 40);
2059 else if (p_ptr->pclass == CLASS_BERSERKER)
2061 p_ptr->num_blow[i] += (p_ptr->lev / 23);
2063 else if ((p_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (p_ptr->stat_ind[A_DEX] >= 30)) p_ptr->num_blow[i] ++;
2065 if (p_ptr->special_defense & KATA_FUUJIN) p_ptr->num_blow[i] -= 1;
2067 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) p_ptr->num_blow[i] = 1;
2070 /* Require at least one blow */
2071 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
2073 /* Boost digging skill by weapon weight */
2074 p_ptr->skill_dig += (o_ptr->weight / 10);
2078 /* Priest weapon penalty for non-blessed edged weapons */
2079 if ((p_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
2080 ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
2082 /* Reduce the real bonuses */
2083 p_ptr->to_h[i] -= 2;
2084 p_ptr->to_d[i] -= 2;
2086 /* Reduce the mental bonuses */
2087 p_ptr->dis_to_h[i] -= 2;
2088 p_ptr->dis_to_d[i] -= 2;
2091 p_ptr->icky_wield[i] = TRUE;
2093 else if (p_ptr->pclass == CLASS_BERSERKER)
2095 p_ptr->to_h[i] += p_ptr->lev / 5;
2096 p_ptr->to_d[i] += p_ptr->lev / 6;
2097 p_ptr->dis_to_h[i] += p_ptr->lev / 5;
2098 p_ptr->dis_to_d[i] += p_ptr->lev / 6;
2099 if (((i == 0) && !p_ptr->hidarite) || p_ptr->ryoute)
2101 p_ptr->to_h[i] += p_ptr->lev / 5;
2102 p_ptr->to_d[i] += p_ptr->lev / 6;
2103 p_ptr->dis_to_h[i] += p_ptr->lev / 5;
2104 p_ptr->dis_to_d[i] += p_ptr->lev / 6;
2107 else if (p_ptr->pclass == CLASS_SORCERER)
2109 if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
2111 /* Reduce the real bonuses */
2112 p_ptr->to_h[i] -= 200;
2113 p_ptr->to_d[i] -= 200;
2115 /* Reduce the mental bonuses */
2116 p_ptr->dis_to_h[i] -= 200;
2117 p_ptr->dis_to_d[i] -= 200;
2120 p_ptr->icky_wield[i] = TRUE;
2124 /* Reduce the real bonuses */
2125 p_ptr->to_h[i] -= 30;
2126 p_ptr->to_d[i] -= 10;
2128 /* Reduce the mental bonuses */
2129 p_ptr->dis_to_h[i] -= 30;
2130 p_ptr->dis_to_d[i] -= 10;
2134 if (p_ptr->realm1 == REALM_HEX)
2136 if (object_is_cursed(o_ptr))
2138 if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
2139 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_h[i] += 7; p_ptr->dis_to_h[i] += 7; }
2140 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_h[i] += 13; p_ptr->dis_to_h[i] += 13; }
2141 if (o_ptr->curse_flags & (TRC_TY_CURSE)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
2142 if (hex_spelling(HEX_RUNESWORD))
2144 if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_d[i] += 5; p_ptr->dis_to_d[i] += 5; }
2145 if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_d[i] += 7; p_ptr->dis_to_d[i] += 7; }
2146 if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_d[i] += 13; p_ptr->dis_to_d[i] += 13; }
2152 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2154 p_ptr->to_h[i] += 15;
2155 p_ptr->dis_to_h[i] += 15;
2156 p_ptr->to_dd[i] += 2;
2158 else if (!(have_flag(flgs, TR_RIDING)))
2161 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
2167 penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
2169 if (penalty < 30) penalty = 30;
2171 p_ptr->to_h[i] -= (s16b)penalty;
2172 p_ptr->dis_to_h[i] -= (s16b)penalty;
2175 p_ptr->riding_wield[i] = TRUE;
2184 p_ptr->riding_ryoute = FALSE;
2186 if (p_ptr->ryoute || (empty_hands(FALSE) == EMPTY_HAND_NONE)) p_ptr->riding_ryoute = TRUE;
2187 else if (p_ptr->pet_extra_flags & PF_RYOUTE)
2189 switch (p_ptr->pclass)
2192 case CLASS_FORCETRAINER:
2193 case CLASS_BERSERKER:
2194 if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
2195 p_ptr->riding_ryoute = TRUE;
2200 if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
2202 if (p_ptr->tval_ammo != TV_ARROW) penalty = 5;
2206 penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
2208 if (penalty < 30) penalty = 30;
2210 if (p_ptr->tval_ammo == TV_BOLT) penalty *= 2;
2211 p_ptr->to_h_b -= (s16b)penalty;
2212 p_ptr->dis_to_h_b -= (s16b)penalty;
2215 /* Different calculation for monks with empty hands */
2216 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) &&
2217 (empty_hands_status & EMPTY_HAND_RARM) && !p_ptr->hidarite)
2219 int blow_base = p_ptr->lev + adj_dex_blow[p_ptr->stat_ind[A_DEX]];
2220 p_ptr->num_blow[0] = 0;
2222 if (p_ptr->pclass == CLASS_FORCETRAINER)
2224 if (blow_base > 18) p_ptr->num_blow[0]++;
2225 if (blow_base > 31) p_ptr->num_blow[0]++;
2226 if (blow_base > 44) p_ptr->num_blow[0]++;
2227 if (blow_base > 58) p_ptr->num_blow[0]++;
2230 p_ptr->to_d[0] += P_PTR_KI / 5;
2231 p_ptr->dis_to_d[0] += P_PTR_KI / 5;
2236 if (blow_base > 12) p_ptr->num_blow[0]++;
2237 if (blow_base > 22) p_ptr->num_blow[0]++;
2238 if (blow_base > 31) p_ptr->num_blow[0]++;
2239 if (blow_base > 39) p_ptr->num_blow[0]++;
2240 if (blow_base > 46) p_ptr->num_blow[0]++;
2241 if (blow_base > 53) p_ptr->num_blow[0]++;
2242 if (blow_base > 59) p_ptr->num_blow[0]++;
2245 if (heavy_armor() && (p_ptr->pclass != CLASS_BERSERKER))
2246 p_ptr->num_blow[0] /= 2;
2249 p_ptr->to_h[0] += (p_ptr->lev / 3);
2250 p_ptr->dis_to_h[0] += (p_ptr->lev / 3);
2252 p_ptr->to_d[0] += (p_ptr->lev / 6);
2253 p_ptr->dis_to_d[0] += (p_ptr->lev / 6);
2256 if (p_ptr->special_defense & KAMAE_BYAKKO)
2259 p_ptr->dis_to_a -= 40;
2262 else if (p_ptr->special_defense & KAMAE_SEIRYU)
2265 p_ptr->dis_to_a -= 50;
2266 p_ptr->resist_acid = TRUE;
2267 p_ptr->resist_fire = TRUE;
2268 p_ptr->resist_elec = TRUE;
2269 p_ptr->resist_cold = TRUE;
2270 p_ptr->resist_pois = TRUE;
2271 p_ptr->sh_fire = TRUE;
2272 p_ptr->sh_elec = TRUE;
2273 p_ptr->sh_cold = TRUE;
2274 p_ptr->levitation = TRUE;
2276 else if (p_ptr->special_defense & KAMAE_GENBU)
2278 p_ptr->to_a += (p_ptr->lev*p_ptr->lev) / 50;
2279 p_ptr->dis_to_a += (p_ptr->lev*p_ptr->lev) / 50;
2280 p_ptr->reflect = TRUE;
2281 p_ptr->num_blow[0] -= 2;
2282 if ((p_ptr->pclass == CLASS_MONK) && (p_ptr->lev > 42)) p_ptr->num_blow[0]--;
2283 if (p_ptr->num_blow[0] < 0) p_ptr->num_blow[0] = 0;
2285 else if (p_ptr->special_defense & KAMAE_SUZAKU)
2287 p_ptr->to_h[0] -= (p_ptr->lev / 3);
2288 p_ptr->to_d[0] -= (p_ptr->lev / 6);
2290 p_ptr->dis_to_h[0] -= (p_ptr->lev / 3);
2291 p_ptr->dis_to_d[0] -= (p_ptr->lev / 6);
2292 p_ptr->num_blow[0] /= 2;
2293 p_ptr->levitation = TRUE;
2296 p_ptr->num_blow[0] += 1 + extra_blows[0];
2299 if (p_ptr->riding) p_ptr->levitation = riding_levitation;
2301 monk_armour_aux = FALSE;
2305 monk_armour_aux = TRUE;
2308 for (i = 0; i < 2; i++)
2310 if (has_melee_weapon(INVEN_RARM + i))
2312 OBJECT_TYPE_VALUE tval = inventory[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
2313 OBJECT_SUBTYPE_VALUE sval = inventory[INVEN_RARM + i].sval;
2315 p_ptr->to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2316 p_ptr->dis_to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
2317 if ((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER))
2319 if (!s_info[p_ptr->pclass].w_max[tval][sval])
2321 p_ptr->to_h[i] -= 40;
2322 p_ptr->dis_to_h[i] -= 40;
2323 p_ptr->icky_wield[i] = TRUE;
2326 else if (p_ptr->pclass == CLASS_NINJA)
2328 if ((s_info[CLASS_NINJA].w_max[tval][sval] <= WEAPON_EXP_BEGINNER) || (inventory[INVEN_LARM - i].tval == TV_SHIELD))
2330 p_ptr->to_h[i] -= 40;
2331 p_ptr->dis_to_h[i] -= 40;
2332 p_ptr->icky_wield[i] = TRUE;
2333 p_ptr->num_blow[i] /= 2;
2334 if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
2338 if (inventory[INVEN_RARM + i].name1 == ART_IRON_BALL) p_ptr->align -= 1000;
2342 /* Maximum speed is (+99). (internally it's 110 + 99) */
2343 /* Temporary lightspeed forces to be maximum speed */
2344 if ((p_ptr->lightspeed && !p_ptr->riding) || (new_speed > 209))
2349 /* Minimum speed is (-99). (internally it's 110 - 99) */
2350 if (new_speed < 11) new_speed = 11;
2352 /* Display the speed (if needed) */
2353 if (p_ptr->pspeed != (byte)new_speed)
2355 p_ptr->pspeed = (byte)new_speed;
2356 p_ptr->redraw |= (PR_SPEED);
2361 if (p_ptr->to_a > (0 - p_ptr->ac))
2362 p_ptr->to_a = 0 - p_ptr->ac;
2363 if (p_ptr->dis_to_a > (0 - p_ptr->dis_ac))
2364 p_ptr->dis_to_a = 0 - p_ptr->dis_ac;
2367 /* Redraw armor (if needed) */
2368 if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
2370 p_ptr->redraw |= (PR_ARMOR);
2371 p_ptr->window |= (PW_PLAYER);
2374 if (p_ptr->ryoute && !omoi)
2376 int bonus_to_h = 0, bonus_to_d = 0;
2377 bonus_to_d = ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128) / 2;
2378 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);
2380 p_ptr->to_h[default_hand] += MAX(bonus_to_h, 1);
2381 p_ptr->dis_to_h[default_hand] += MAX(bonus_to_h, 1);
2382 p_ptr->to_d[default_hand] += MAX(bonus_to_d, 1);
2383 p_ptr->dis_to_d[default_hand] += MAX(bonus_to_d, 1);
2386 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;
2388 /* Affect Skill -- stealth (bonus one) */
2389 p_ptr->skill_stl += 1;
2391 if (IS_TIM_STEALTH()) p_ptr->skill_stl += 99;
2393 /* Affect Skill -- disarming (DEX and INT) */
2394 p_ptr->skill_dis += adj_dex_dis[p_ptr->stat_ind[A_DEX]];
2395 p_ptr->skill_dis += adj_int_dis[p_ptr->stat_ind[A_INT]];
2397 /* Affect Skill -- magic devices (INT) */
2398 p_ptr->skill_dev += adj_int_dev[p_ptr->stat_ind[A_INT]];
2400 /* Affect Skill -- saving throw (WIS) */
2401 p_ptr->skill_sav += adj_wis_sav[p_ptr->stat_ind[A_WIS]];
2403 /* Affect Skill -- digging (STR) */
2404 p_ptr->skill_dig += adj_str_dig[p_ptr->stat_ind[A_STR]];
2406 /* Affect Skill -- disarming (Level, by Class) */
2407 p_ptr->skill_dis += ((cp_ptr->x_dis * p_ptr->lev / 10) + (ap_ptr->a_dis * p_ptr->lev / 50));
2409 /* Affect Skill -- magic devices (Level, by Class) */
2410 p_ptr->skill_dev += ((cp_ptr->x_dev * p_ptr->lev / 10) + (ap_ptr->a_dev * p_ptr->lev / 50));
2412 /* Affect Skill -- saving throw (Level, by Class) */
2413 p_ptr->skill_sav += ((cp_ptr->x_sav * p_ptr->lev / 10) + (ap_ptr->a_sav * p_ptr->lev / 50));
2415 /* Affect Skill -- stealth (Level, by Class) */
2416 p_ptr->skill_stl += (cp_ptr->x_stl * p_ptr->lev / 10);
2418 /* Affect Skill -- search ability (Level, by Class) */
2419 p_ptr->skill_srh += (cp_ptr->x_srh * p_ptr->lev / 10);
2421 /* Affect Skill -- search frequency (Level, by Class) */
2422 p_ptr->skill_fos += (cp_ptr->x_fos * p_ptr->lev / 10);
2424 /* Affect Skill -- combat (normal) (Level, by Class) */
2425 p_ptr->skill_thn += ((cp_ptr->x_thn * p_ptr->lev / 10) + (ap_ptr->a_thn * p_ptr->lev / 50));
2427 /* Affect Skill -- combat (shooting) (Level, by Class) */
2428 p_ptr->skill_thb += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
2430 /* Affect Skill -- combat (throwing) (Level, by Class) */
2431 p_ptr->skill_tht += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
2434 if ((prace_is_(RACE_S_FAIRY)) && (p_ptr->pseikaku != SEIKAKU_SEXY) && (p_ptr->cursed & TRC_AGGRAVATE))
2436 p_ptr->cursed &= ~(TRC_AGGRAVATE);
2437 p_ptr->skill_stl = MIN(p_ptr->skill_stl - 3, (p_ptr->skill_stl + 2) / 2);
2440 /* Limit Skill -- stealth from 0 to 30 */
2441 if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
2442 if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;
2444 /* Limit Skill -- digging from 1 up */
2445 if (p_ptr->skill_dig < 1) p_ptr->skill_dig = 1;
2447 if (p_ptr->anti_magic && (p_ptr->skill_sav < (90 + p_ptr->lev))) p_ptr->skill_sav = 90 + p_ptr->lev;
2449 if (p_ptr->tsubureru) p_ptr->skill_sav = 10;
2451 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;
2453 if (down_saving) p_ptr->skill_sav /= 2;
2455 /* Hack -- Each elemental immunity includes resistance */
2456 if (p_ptr->immune_acid) p_ptr->resist_acid = TRUE;
2457 if (p_ptr->immune_elec) p_ptr->resist_elec = TRUE;
2458 if (p_ptr->immune_fire) p_ptr->resist_fire = TRUE;
2459 if (p_ptr->immune_cold) p_ptr->resist_cold = TRUE;
2461 /* Determine player alignment */
2462 for (i = 0, j = 0; i < 8; i++)
2464 switch (p_ptr->vir_types[i])
2467 p_ptr->align += p_ptr->virtues[i] * 2;
2477 p_ptr->align -= p_ptr->virtues[i];
2480 p_ptr->align += p_ptr->virtues[i];
2485 for (i = 0; i < j; i++)
2487 if (p_ptr->align > 0)
2489 p_ptr->align -= p_ptr->virtues[neutral[i]] / 2;
2490 if (p_ptr->align < 0) p_ptr->align = 0;
2492 else if (p_ptr->align < 0)
2494 p_ptr->align += p_ptr->virtues[neutral[i]] / 2;
2495 if (p_ptr->align > 0) p_ptr->align = 0;
2499 /* Hack -- handle "xtra" mode */
2500 if (character_xtra) return;
2502 /* Take note when "heavy bow" changes */
2503 if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
2505 if (p_ptr->heavy_shoot)
2507 msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
2509 else if (inventory[INVEN_BOW].k_idx)
2511 msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
2515 msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
2519 p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
2522 for (i = 0; i < 2; i++)
2524 /* Take note when "heavy weapon" changes */
2525 if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
2527 if (p_ptr->heavy_wield[i])
2529 msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
2531 else if (has_melee_weapon(INVEN_RARM + i))
2533 msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
2535 else if (p_ptr->heavy_wield[1 - i])
2537 msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
2541 msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
2545 p_ptr->old_heavy_wield[i] = p_ptr->heavy_wield[i];
2548 /* Take note when "heavy weapon" changes */
2549 if (p_ptr->old_riding_wield[i] != p_ptr->riding_wield[i])
2551 if (p_ptr->riding_wield[i])
2553 msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
2555 else if (!p_ptr->riding)
2557 msg_print(_("この武器は徒歩で使いやすい。", "This weapon was not suitable for use while riding."));
2559 else if (has_melee_weapon(INVEN_RARM + i))
2561 msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
2564 p_ptr->old_riding_wield[i] = p_ptr->riding_wield[i];
2567 /* Take note when "illegal weapon" changes */
2568 if (p_ptr->old_icky_wield[i] != p_ptr->icky_wield[i])
2570 if (p_ptr->icky_wield[i])
2572 msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
2575 chg_virtue(V_FAITH, -1);
2578 else if (has_melee_weapon(INVEN_RARM + i))
2580 msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
2584 msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
2588 p_ptr->old_icky_wield[i] = p_ptr->icky_wield[i];
2592 if (p_ptr->riding && (p_ptr->old_riding_ryoute != p_ptr->riding_ryoute))
2594 if (p_ptr->riding_ryoute)
2597 msg_format("%s馬を操れない。", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
2599 msg_print("You are using both hand for fighting, and you can't control a riding pet.");
2605 msg_format("%s馬を操れるようになった。", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
2607 msg_print("You began to control riding pet with one hand.");
2611 p_ptr->old_riding_ryoute = p_ptr->riding_ryoute;
2614 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && (monk_armour_aux != monk_notify_aux))
2618 msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
2621 chg_virtue(V_HARMONY, -1);
2626 msg_print(_("バランスがとれるようになった。", "You regain your balance."));
2629 monk_notify_aux = monk_armour_aux;
2632 for (i = 0; i < INVEN_PACK; i++)
2635 if ((inventory[i].tval == TV_SORCERY_BOOK) && (inventory[i].sval == 2)) have_dd_s = TRUE;
2636 if ((inventory[i].tval == TV_TRUMP_BOOK) && (inventory[i].sval == 1)) have_dd_t = TRUE;
2638 if ((inventory[i].tval == TV_NATURE_BOOK) && (inventory[i].sval == 2)) have_sw = TRUE;
2639 if ((inventory[i].tval == TV_CRAFT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
2642 for (this_o_idx = grid_array[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2644 o_ptr = &o_list[this_o_idx];
2646 /* Acquire next object */
2647 next_o_idx = o_ptr->next_o_idx;
2650 if ((o_ptr->tval == TV_SORCERY_BOOK) && (o_ptr->sval == 3)) have_dd_s = TRUE;
2651 if ((o_ptr->tval == TV_TRUMP_BOOK) && (o_ptr->sval == 1)) have_dd_t = TRUE;
2653 if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
2654 if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
2657 if (p_ptr->pass_wall && !p_ptr->kill_wall) p_ptr->no_flowed = TRUE;
2659 if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER)))
2661 const magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY - 1][SPELL_DD_S];
2662 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2665 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)))
2667 const magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP - 1][SPELL_DD_T];
2668 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2671 if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER)))
2673 const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE - 1][SPELL_SW];
2674 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2677 if (have_kabe && ((p_ptr->realm1 == REALM_CRAFT) || (p_ptr->realm2 == REALM_CRAFT) || (p_ptr->pclass == CLASS_SORCERER)))
2679 const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT - 1][SPELL_KABE];
2680 if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
2686 * @brief プレイヤーの最大HPを計算する /
2687 * Calculate the players (maximal) hit points
2688 * Adjust current hitpoints if necessary
2692 static void calc_hitpoints(void)
2697 /* Un-inflate "half-hitpoint bonus per level" value */
2698 bonus = ((int)(adj_con_mhp[p_ptr->stat_ind[A_CON]]) - 128) * p_ptr->lev / 4;
2700 /* Calculate hitpoints */
2701 mhp = p_ptr->player_hp[p_ptr->lev - 1];
2703 if (p_ptr->mimic_form)
2705 if (p_ptr->pclass == CLASS_SORCERER)
2706 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
2708 tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
2709 mhp = mhp * tmp_hitdie / p_ptr->hitdie;
2712 if (p_ptr->pclass == CLASS_SORCERER)
2714 if (p_ptr->lev < 30)
2715 mhp = (mhp * (45 + p_ptr->lev) / 100);
2717 mhp = (mhp * 75 / 100);
2718 bonus = (bonus * 65 / 100);
2723 if (p_ptr->pclass == CLASS_BERSERKER)
2725 mhp = mhp * (110 + (((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 110)) / 100;
2728 /* Always have at least one hitpoint per level */
2729 if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1;
2731 /* Factor in the hero / superhero settings */
2732 if (IS_HERO()) mhp += 10;
2733 if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
2734 if (p_ptr->tsuyoshi) mhp += 50;
2736 /* Factor in the hex spell settings */
2737 if (hex_spelling(HEX_XTRA_MIGHT)) mhp += 15;
2738 if (hex_spelling(HEX_BUILDING)) mhp += 60;
2740 /* New maximum hitpoints */
2741 if (p_ptr->mhp != mhp)
2743 /* Enforce maximum */
2744 if (p_ptr->chp >= mhp)
2747 p_ptr->chp_frac = 0;
2751 /* レベルアップの時は上昇量を表示する */
2752 if ((level_up == 1) && (mhp > p_ptr->mhp))
2754 msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - p_ptr->mhp));
2757 /* Save the new max-hitpoints */
2760 /* Display hitpoints (later) */
2761 p_ptr->redraw |= (PR_HP);
2763 p_ptr->window |= (PW_PLAYER);
2768 * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
2771 * SWD: Experimental modification: multiple light sources have additive effect.
2773 static void calc_torch(void)
2777 BIT_FLAGS flgs[TR_FLAG_SIZE];
2779 /* Assume no light */
2780 p_ptr->cur_lite = 0;
2782 /* Loop through all wielded items */
2783 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2785 o_ptr = &inventory[i];
2786 /* Skip empty slots */
2787 if (!o_ptr->k_idx) continue;
2789 if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
2792 if (o_ptr->name2 != EGO_LITE_DARKNESS)
2794 if (o_ptr->tval == TV_LITE)
2796 if ((o_ptr->sval == SV_LITE_TORCH) && !(o_ptr->xtra4 > 0)) continue;
2797 if ((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
2800 object_flags(o_ptr, flgs);
2802 /* calc the lite_radius */
2805 if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 1;
2806 if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 2;
2807 if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS) rad += 3;
2808 if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
2809 if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
2810 if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
2811 p_ptr->cur_lite += (s16b)rad;
2814 /* max radius is 14 (was 5) without rewriting other code -- */
2815 /* see grid_array.c:update_lite() and defines.h:LITE_MAX */
2816 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
2817 p_ptr->cur_lite = 1;
2820 * check if the player doesn't have light radius,
2821 * but does weakly glow as an intrinsic.
2823 if (p_ptr->cur_lite <= 0 && p_ptr->lite) p_ptr->cur_lite++;
2825 if (p_ptr->cur_lite > 14) p_ptr->cur_lite = 14;
2826 if (p_ptr->cur_lite < 0) p_ptr->cur_lite = 0;
2828 /* end experimental mods */
2830 /* Notice changes in the "lite radius" */
2831 if (p_ptr->old_lite != p_ptr->cur_lite)
2833 /* Hack -- PU_MON_LITE for monsters' darkness */
2834 p_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
2836 /* Remember the old lite */
2837 p_ptr->old_lite = p_ptr->cur_lite;
2839 if ((p_ptr->cur_lite > 0) && (p_ptr->special_defense & NINJA_S_STEALTH))
2840 set_superstealth(FALSE);
2845 * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
2846 * Calculate number of spells player should have, and forget,
2847 * or remember, spells until that number is properly reflected.
2850 * Note that this function induces various "status" messages,
2851 * which must be bypasses until the character is created.
2853 static void calc_spells(void)
2855 int i, j, k, levels;
2857 int num_boukyaku = 0;
2859 const magic_type *s_ptr;
2866 /* Hack -- must be literate */
2867 if (!mp_ptr->spell_book) return;
2869 /* Hack -- wait for creation */
2870 if (!character_generated) return;
2872 /* Hack -- handle "xtra" mode */
2873 if (character_xtra) return;
2875 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
2877 p_ptr->new_spells = 0;
2881 p = spell_category_name(mp_ptr->spell_book);
2883 /* Determine the number of spells allowed */
2884 levels = p_ptr->lev - mp_ptr->spell_first + 1;
2886 /* Hack -- no negative spells */
2887 if (levels < 0) levels = 0;
2889 /* Extract total allowed spells */
2890 num_allowed = (adj_mag_study[p_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
2892 if ((p_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
2896 if (p_ptr->pclass == CLASS_SAMURAI)
2900 else if (p_ptr->realm2 == REALM_NONE)
2902 num_allowed = (num_allowed + 1) / 2;
2903 if (num_allowed > (32 + bonus)) num_allowed = 32 + bonus;
2905 else if ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))
2907 if (num_allowed > (96 + bonus)) num_allowed = 96 + bonus;
2911 if (num_allowed > (80 + bonus)) num_allowed = 80 + bonus;
2914 /* Count the number of spells we know */
2915 for (j = 0; j < 64; j++)
2917 /* Count known spells */
2919 (p_ptr->spell_forgotten1 & (1L << j)) :
2920 (p_ptr->spell_forgotten2 & (1L << (j - 32))))
2926 /* See how many spells we must forget or may learn */
2927 p_ptr->new_spells = num_allowed + p_ptr->add_spells + num_boukyaku - p_ptr->learned_spells;
2929 /* Forget spells which are too hard */
2930 for (i = 63; i >= 0; i--)
2932 /* Efficiency -- all done */
2933 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
2935 /* Access the spell */
2936 j = p_ptr->spell_order[i];
2938 /* Skip non-spells */
2939 if (j >= 99) continue;
2943 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
2946 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
2948 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j % 32];
2951 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
2953 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][j % 32];
2955 /* Skip spells we are allowed to know */
2956 if (s_ptr->slevel <= p_ptr->lev) continue;
2960 (p_ptr->spell_learned1 & (1L << j)) :
2961 (p_ptr->spell_learned2 & (1L << (j - 32))))
2963 /* Mark as forgotten */
2966 p_ptr->spell_forgotten1 |= (1L << j);
2967 which = p_ptr->realm1;
2971 p_ptr->spell_forgotten2 |= (1L << (j - 32));
2972 which = p_ptr->realm2;
2975 /* No longer known */
2978 p_ptr->spell_learned1 &= ~(1L << j);
2979 which = p_ptr->realm1;
2983 p_ptr->spell_learned2 &= ~(1L << (j - 32));
2984 which = p_ptr->realm2;
2988 msg_format("%sの%sを忘れてしまった。", do_spell(which, j % 32, SPELL_NAME), p);
2990 msg_format("You have forgotten the %s of %s.", p, do_spell(which, j % 32, SPELL_NAME));
2994 /* One more can be learned */
2995 p_ptr->new_spells++;
3000 /* Forget spells if we know too many spells */
3001 for (i = 63; i >= 0; i--)
3003 /* Stop when possible */
3004 if (p_ptr->new_spells >= 0) break;
3006 /* Efficiency -- all done */
3007 if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
3009 /* Get the (i+1)th spell learned */
3010 j = p_ptr->spell_order[i];
3012 /* Skip unknown spells */
3013 if (j >= 99) continue;
3015 /* Forget it (if learned) */
3017 (p_ptr->spell_learned1 & (1L << j)) :
3018 (p_ptr->spell_learned2 & (1L << (j - 32))))
3020 /* Mark as forgotten */
3023 p_ptr->spell_forgotten1 |= (1L << j);
3024 which = p_ptr->realm1;
3028 p_ptr->spell_forgotten2 |= (1L << (j - 32));
3029 which = p_ptr->realm2;
3032 /* No longer known */
3035 p_ptr->spell_learned1 &= ~(1L << j);
3036 which = p_ptr->realm1;
3040 p_ptr->spell_learned2 &= ~(1L << (j - 32));
3041 which = p_ptr->realm2;
3045 msg_format("%sの%sを忘れてしまった。",
3046 do_spell(which, j % 32, SPELL_NAME), p);
3048 msg_format("You have forgotten the %s of %s.", p,
3049 do_spell(which, j % 32, SPELL_NAME));
3053 /* One more can be learned */
3054 p_ptr->new_spells++;
3059 /* Check for spells to remember */
3060 for (i = 0; i < 64; i++)
3062 /* None left to remember */
3063 if (p_ptr->new_spells <= 0) break;
3065 /* Efficiency -- all done */
3066 if (!p_ptr->spell_forgotten1 && !p_ptr->spell_forgotten2) break;
3068 /* Get the next spell we learned */
3069 j = p_ptr->spell_order[i];
3071 /* Skip unknown spells */
3074 /* Access the spell */
3075 if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
3078 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
3080 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j % 32];
3083 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
3085 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][j % 32];
3087 /* Skip spells we cannot remember */
3088 if (s_ptr->slevel > p_ptr->lev) continue;
3090 /* First set of spells */
3092 (p_ptr->spell_forgotten1 & (1L << j)) :
3093 (p_ptr->spell_forgotten2 & (1L << (j - 32))))
3095 /* No longer forgotten */
3098 p_ptr->spell_forgotten1 &= ~(1L << j);
3099 which = p_ptr->realm1;
3103 p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
3104 which = p_ptr->realm2;
3107 /* Known once more */
3110 p_ptr->spell_learned1 |= (1L << j);
3111 which = p_ptr->realm1;
3115 p_ptr->spell_learned2 |= (1L << (j - 32));
3116 which = p_ptr->realm2;
3120 msg_format("%sの%sを思い出した。", do_spell(which, j % 32, SPELL_NAME), p);
3122 msg_format("You have remembered the %s of %s.", p, do_spell(which, j % 32, SPELL_NAME));
3126 /* One less can be learned */
3127 p_ptr->new_spells--;
3133 if (p_ptr->realm2 == REALM_NONE)
3135 /* Count spells that can be learned */
3136 for (j = 0; j < 32; j++)
3138 if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
3139 else s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
3141 /* Skip spells we cannot remember */
3142 if (s_ptr->slevel > p_ptr->lev) continue;
3144 /* Skip spells we already know */
3145 if (p_ptr->spell_learned1 & (1L << j))
3154 if ((p_ptr->new_spells > k) &&
3155 ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
3157 p_ptr->new_spells = (s16b)k;
3161 if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
3163 /* Spell count changed */
3164 if (p_ptr->old_spells != p_ptr->new_spells)
3166 /* Message if needed */
3167 if (p_ptr->new_spells)
3170 if (p_ptr->new_spells < 10) {
3171 msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
3174 msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
3177 msg_format("You can learn %d more %s%s.",
3178 p_ptr->new_spells, p,
3179 (p_ptr->new_spells != 1) ? "s" : "");
3184 /* Save the new_spells value */
3185 p_ptr->old_spells = p_ptr->new_spells;
3187 /* Redraw Study Status */
3188 p_ptr->redraw |= (PR_STUDY);
3190 /* Redraw object recall */
3191 p_ptr->window |= (PW_OBJECT);
3196 * @brief プレイヤーの最大MPを計算する /
3197 * Calculate maximum mana. You do not need to know any spells.
3198 * Note that mana is lowered by heavy (or inappropriate) armor.
3201 * This function induces status messages.
3203 static void calc_mana(void)
3205 int msp, levels, cur_wgt, max_wgt;
3210 /* Hack -- Must be literate */
3211 if (!mp_ptr->spell_book) return;
3213 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3214 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3215 (p_ptr->pclass == CLASS_BLUE_MAGE))
3217 levels = p_ptr->lev;
3221 if (mp_ptr->spell_first > p_ptr->lev)
3226 /* Display mana later */
3227 p_ptr->redraw |= (PR_MANA);
3231 /* Extract "effective" player level */
3232 levels = (p_ptr->lev - mp_ptr->spell_first) + 1;
3235 if (p_ptr->pclass == CLASS_SAMURAI)
3237 msp = (adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
3238 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
3242 /* Extract total mana */
3243 msp = adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] * (levels + 3) / 4;
3245 /* Hack -- usually add one mana */
3248 if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
3250 if (msp && (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp / 2;
3252 /* Hack: High mages have a 25% mana bonus */
3253 if (msp && (p_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
3255 if (msp && (p_ptr->pclass == CLASS_SORCERER)) msp += msp * (25 + p_ptr->lev) / 100;
3258 /* Only mages are affected */
3259 if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
3261 BIT_FLAGS flgs[TR_FLAG_SIZE];
3263 /* Assume player is not encumbered by gloves */
3264 p_ptr->cumber_glove = FALSE;
3266 /* Get the gloves */
3267 o_ptr = &inventory[INVEN_HANDS];
3269 /* Examine the gloves */
3270 object_flags(o_ptr, flgs);
3272 /* Normal gloves hurt mage-type spells */
3274 !(have_flag(flgs, TR_FREE_ACT)) &&
3275 !(have_flag(flgs, TR_DEC_MANA)) &&
3276 !(have_flag(flgs, TR_EASY_SPELL)) &&
3277 !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
3278 !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
3281 p_ptr->cumber_glove = TRUE;
3284 msp = (3 * msp) / 4;
3289 /* Assume player not encumbered by armor */
3290 p_ptr->cumber_armor = FALSE;
3292 /* Weigh the armor */
3294 if (inventory[INVEN_RARM].tval > TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
3295 if (inventory[INVEN_LARM].tval > TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
3296 cur_wgt += inventory[INVEN_BODY].weight;
3297 cur_wgt += inventory[INVEN_HEAD].weight;
3298 cur_wgt += inventory[INVEN_OUTER].weight;
3299 cur_wgt += inventory[INVEN_HANDS].weight;
3300 cur_wgt += inventory[INVEN_FEET].weight;
3302 /* Subtract a percentage of maximum mana. */
3303 switch (p_ptr->pclass)
3305 /* For these classes, mana is halved if armour
3306 * is 30 pounds over their weight limit. */
3308 case CLASS_HIGH_MAGE:
3309 case CLASS_BLUE_MAGE:
3311 case CLASS_FORCETRAINER:
3312 case CLASS_SORCERER:
3314 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
3315 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
3319 /* Mana halved if armour is 40 pounds over weight limit. */
3324 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight * 2 / 3;
3325 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight * 2 / 3;
3329 case CLASS_MINDCRAFTER:
3330 case CLASS_BEASTMASTER:
3331 case CLASS_MIRROR_MASTER:
3333 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight / 2;
3334 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight / 2;
3338 /* Mana halved if armour is 50 pounds over weight limit. */
3341 case CLASS_RED_MAGE:
3342 case CLASS_WARRIOR_MAGE:
3344 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight / 3;
3345 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight / 3;
3349 /* Mana halved if armour is 60 pounds over weight limit. */
3351 case CLASS_CHAOS_WARRIOR:
3353 if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight / 5;
3354 if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight / 5;
3358 /* For new classes created, but not yet added to this formula. */
3365 /* Determine the weight allowance */
3366 max_wgt = mp_ptr->spell_weight;
3368 /* Heavy armor penalizes mana by a percentage. -LM- */
3369 if ((cur_wgt - max_wgt) > 0)
3372 p_ptr->cumber_armor = TRUE;
3374 /* Subtract a percentage of maximum mana. */
3375 switch (p_ptr->pclass)
3377 /* For these classes, mana is halved if armour
3378 * is 30 pounds over their weight limit. */
3380 case CLASS_HIGH_MAGE:
3381 case CLASS_BLUE_MAGE:
3383 msp -= msp * (cur_wgt - max_wgt) / 600;
3387 /* Mana halved if armour is 40 pounds over weight limit. */
3389 case CLASS_MINDCRAFTER:
3390 case CLASS_BEASTMASTER:
3392 case CLASS_FORCETRAINER:
3394 case CLASS_MIRROR_MASTER:
3396 msp -= msp * (cur_wgt - max_wgt) / 800;
3400 case CLASS_SORCERER:
3402 msp -= msp * (cur_wgt - max_wgt) / 900;
3406 /* Mana halved if armour is 50 pounds over weight limit. */
3410 case CLASS_RED_MAGE:
3412 msp -= msp * (cur_wgt - max_wgt) / 1000;
3416 /* Mana halved if armour is 60 pounds over weight limit. */
3418 case CLASS_CHAOS_WARRIOR:
3419 case CLASS_WARRIOR_MAGE:
3421 msp -= msp * (cur_wgt - max_wgt) / 1200;
3427 p_ptr->cumber_armor = FALSE;
3431 /* For new classes created, but not yet added to this formula. */
3434 msp -= msp * (cur_wgt - max_wgt) / 800;
3440 /* Mana can never be negative */
3441 if (msp < 0) msp = 0;
3444 /* Maximum mana has changed */
3445 if (p_ptr->msp != msp)
3447 /* Enforce maximum */
3448 if ((p_ptr->csp >= msp) && (p_ptr->pclass != CLASS_SAMURAI))
3451 p_ptr->csp_frac = 0;
3455 /* レベルアップの時は上昇量を表示する */
3456 if ((level_up == 1) && (msp > p_ptr->msp))
3458 msg_format("最大マジック・ポイントが %d 増加した!", (msp - p_ptr->msp));
3464 /* Display mana later */
3465 p_ptr->redraw |= (PR_MANA);
3467 p_ptr->window |= (PW_PLAYER);
3468 p_ptr->window |= (PW_SPELL);
3472 /* Hack -- handle "xtra" mode */
3473 if (character_xtra) return;
3475 /* Take note when "glove state" changes */
3476 if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
3478 if (p_ptr->cumber_glove)
3480 msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
3484 msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
3488 p_ptr->old_cumber_glove = p_ptr->cumber_glove;
3492 /* Take note when "armor state" changes */
3493 if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
3495 if (p_ptr->cumber_armor)
3497 msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
3501 msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
3505 p_ptr->old_cumber_armor = p_ptr->cumber_armor;
3510 * @brief 装備中の射撃武器の威力倍率を返す /
3511 * calcurate the fire rate of target object
3512 * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
3513 * @return 射撃倍率の値(100で1.00倍)
3515 s16b calc_num_fire(object_type *o_ptr)
3517 int extra_shots = 0;
3520 OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
3522 BIT_FLAGS flgs[TR_FLAG_SIZE];
3524 /* Scan the usable inventory */
3525 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3527 q_ptr = &inventory[i];
3529 /* Skip non-objects */
3530 if (!q_ptr->k_idx) continue;
3532 /* Do not apply current equip */
3533 if (i == INVEN_BOW) continue;
3535 /* Extract the item flags */
3536 object_flags(q_ptr, flgs);
3539 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
3542 object_flags(o_ptr, flgs);
3543 if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
3545 if (o_ptr->k_idx && !is_heavy_shoot(o_ptr))
3549 num += (extra_shots * 100);
3551 /* Hack -- Rangers love Bows */
3552 if ((p_ptr->pclass == CLASS_RANGER) &&
3553 (tval_ammo == TV_ARROW))
3555 num += (p_ptr->lev * 4);
3558 if ((p_ptr->pclass == CLASS_CAVALRY) &&
3559 (tval_ammo == TV_ARROW))
3561 num += (p_ptr->lev * 3);
3564 if (p_ptr->pclass == CLASS_ARCHER)
3566 if (tval_ammo == TV_ARROW)
3567 num += ((p_ptr->lev * 5) + 50);
3568 else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
3569 num += (p_ptr->lev * 4);
3573 * Addendum -- also "Reward" high level warriors,
3574 * with _any_ missile weapon -- TY
3576 if (p_ptr->pclass == CLASS_WARRIOR &&
3577 (tval_ammo <= TV_BOLT) &&
3578 (tval_ammo >= TV_SHOT))
3580 num += (p_ptr->lev * 2);
3582 if ((p_ptr->pclass == CLASS_ROGUE) &&
3583 (tval_ammo == TV_SHOT))
3585 num += (p_ptr->lev * 4);
3592 * @brief プレイヤーの所持重量制限を計算する /
3593 * Computes current weight limit.
3596 WEIGHT weight_limit(void)
3600 /* Weight limit based only on strength */
3601 i = (WEIGHT)adj_str_wgt[p_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
3602 if (p_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
3604 /* Return the result */
3609 * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
3610 * @param i 判定する手のID(右手:0 左手:1)
3611 * @return 持っているならばTRUE
3613 bool has_melee_weapon(int i)
3615 return ((inventory[i].k_idx && object_is_melee_weapon(&inventory[i])) ? TRUE : FALSE);
3619 * @brief プレイヤーの現在開いている手の状態を返す
3620 * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
3621 * @return 開いている手のビットフラグ
3623 BIT_FLAGS16 empty_hands(bool riding_control)
3625 BIT_FLAGS16 status = EMPTY_HAND_NONE;
3627 if (!inventory[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
3628 if (!inventory[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
3630 if (riding_control && (status != EMPTY_HAND_NONE) && p_ptr->riding && !(p_ptr->pet_extra_flags & PF_RYOUTE))
3632 if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
3633 else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
3641 * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
3642 * @return ペナルティが適用されるならばTRUE。
3644 bool heavy_armor(void)
3646 WEIGHT monk_arm_wgt = 0;
3648 if ((p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_NINJA)) return FALSE;
3650 /* Weight the armor */
3651 if (inventory[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_RARM].weight;
3652 if (inventory[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_LARM].weight;
3653 monk_arm_wgt += inventory[INVEN_BODY].weight;
3654 monk_arm_wgt += inventory[INVEN_HEAD].weight;
3655 monk_arm_wgt += inventory[INVEN_OUTER].weight;
3656 monk_arm_wgt += inventory[INVEN_HANDS].weight;
3657 monk_arm_wgt += inventory[INVEN_FEET].weight;
3659 return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));
3663 * @brief p_ptr->update のフラグに応じた更新をまとめて行う / Handle "p_ptr->update"
3665 * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
3667 void update_creature(player_type *creature_ptr)
3669 if (!creature_ptr->update) return;
3671 /* Actually do auto-destroy */
3672 if (creature_ptr->update & (PU_AUTODESTROY))
3674 creature_ptr->update &= ~(PU_AUTODESTROY);
3675 autopick_delayed_alter();
3678 /* Combine the pack */
3679 if (creature_ptr->update & (PU_COMBINE))
3681 creature_ptr->update &= ~(PU_COMBINE);
3685 /* Reorder the pack */
3686 if (creature_ptr->update & (PU_REORDER))
3688 creature_ptr->update &= ~(PU_REORDER);
3692 if (creature_ptr->update & (PU_BONUS))
3694 creature_ptr->update &= ~(PU_BONUS);
3698 if (creature_ptr->update & (PU_TORCH))
3700 creature_ptr->update &= ~(PU_TORCH);
3704 if (creature_ptr->update & (PU_HP))
3706 creature_ptr->update &= ~(PU_HP);
3710 if (creature_ptr->update & (PU_MANA))
3712 creature_ptr->update &= ~(PU_MANA);
3716 if (creature_ptr->update & (PU_SPELLS))
3718 creature_ptr->update &= ~(PU_SPELLS);
3722 /* Character is not ready yet, no screen updates */
3723 if (!character_generated) return;
3725 /* Character is in "icky" mode, no screen updates */
3726 if (character_icky) return;
3728 if (creature_ptr->update & (PU_UN_LITE))
3730 creature_ptr->update &= ~(PU_UN_LITE);
3734 if (creature_ptr->update & (PU_UN_VIEW))
3736 creature_ptr->update &= ~(PU_UN_VIEW);
3740 if (creature_ptr->update & (PU_VIEW))
3742 creature_ptr->update &= ~(PU_VIEW);
3746 if (creature_ptr->update & (PU_LITE))
3748 creature_ptr->update &= ~(PU_LITE);
3753 if (creature_ptr->update & (PU_FLOW))
3755 creature_ptr->update &= ~(PU_FLOW);
3759 if (creature_ptr->update & (PU_DISTANCE))
3761 creature_ptr->update &= ~(PU_DISTANCE);
3763 /* Still need to call update_monsters(FALSE) after update_mon_lite() */
3764 /* creature_ptr->update &= ~(PU_MONSTERS); */
3766 update_monsters(TRUE);
3769 if (creature_ptr->update & (PU_MON_LITE))
3771 creature_ptr->update &= ~(PU_MON_LITE);
3776 * Mega-Hack -- Delayed visual update
3777 * Only used if update_view(), update_lite() or update_mon_lite() was called
3779 if (creature_ptr->update & (PU_DELAY_VIS))
3781 creature_ptr->update &= ~(PU_DELAY_VIS);
3782 delayed_visual_update();
3785 if (creature_ptr->update & (PU_MONSTERS))
3787 creature_ptr->update &= ~(PU_MONSTERS);
3788 update_monsters(FALSE);
3793 * @brief プレイヤーが魔道書を一冊も持っていないかを判定する
3794 * @return 魔道書を一冊も持っていないならTRUEを返す
3796 bool player_has_no_spellbooks(void)
3801 for (i = 0; i < INVEN_PACK; i++)
3803 o_ptr = &inventory[i];
3804 if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
3807 for (i = grid_array[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
3810 if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
3816 void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
3818 creature_ptr->energy_use = (ENERGY)need_cost;
3821 void free_turn(player_type *creature_ptr)
3823 creature_ptr->energy_use = 0;