1 #include "combat/shoot.h"
2 #include "combat/snipe.h"
3 #include "core/stuff-handler.h"
4 #include "effect/effect-characteristics.h"
5 #include "effect/spells-effect-util.h"
7 #include "inventory/inventory-object.h"
8 #include "io/targeting.h"
9 #include "main/sound-definitions-table.h"
10 #include "monster/monster-status.h"
11 #include "monster/monster.h"
12 #include "mspell/monster-spell.h"
13 #include "object/artifact.h"
14 #include "object/object-broken.h"
15 #include "object/object-flavor.h"
16 #include "object/object-hook.h"
17 #include "object/object-kind.h"
18 #include "object/object-mark-types.h"
19 #include "object/object2.h"
20 #include "object/sv-bow-types.h"
21 #include "object/tr-types.h"
22 #include "player/avatar.h"
23 #include "player/player-class.h"
24 #include "player/player-personalities-table.h"
25 #include "player/player-skill.h"
26 #include "player/player-status.h"
27 #include "spell/process-effect.h"
28 #include "term/gameterm.h"
29 #include "util/util.h"
30 #include "view/display-main-window.h"
31 #include "world/world-object.h"
34 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
35 * Determines the odds of an object breaking when thrown at a monster
36 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
37 * @param tdam 計算途中のダメージ量
38 * @param m_ptr 目標モンスターの構造体参照ポインタ
39 * @return スレイ倍率をかけたダメージ量
41 static MULTIPLY calc_shot_damage_with_slay(player_type *sniper_ptr, object_type *o_ptr, HIT_POINT tdam, monster_type *m_ptr, SPELL_IDX snipe_type)
45 monster_race *r_ptr = &r_info[m_ptr->r_idx];
47 BIT_FLAGS flgs[TR_FLAG_SIZE];
48 object_flags(o_ptr, flgs);
50 /* Some "weapons" and "ammo" do extra damage */
57 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
59 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
61 r_ptr->r_flags3 |= RF3_ANIMAL;
63 if (mult < 17) mult = 17;
66 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
68 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
70 r_ptr->r_flags3 |= RF3_ANIMAL;
72 if (mult < 27) mult = 27;
75 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
77 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
79 r_ptr->r_flags3 |= RF3_EVIL;
81 if (mult < 15) mult = 15;
84 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
86 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
88 r_ptr->r_flags3 |= RF3_EVIL;
90 if (mult < 25) mult = 25;
93 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
95 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
97 r_ptr->r_flags2 |= RF2_HUMAN;
99 if (mult < 17) mult = 17;
102 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
104 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
106 r_ptr->r_flags2 |= RF2_HUMAN;
108 if (mult < 27) mult = 27;
111 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
113 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
115 r_ptr->r_flags3 |= RF3_UNDEAD;
117 if (mult < 20) mult = 20;
120 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
122 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
124 r_ptr->r_flags3 |= RF3_UNDEAD;
126 if (mult < 30) mult = 30;
129 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
131 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
133 r_ptr->r_flags3 |= RF3_DEMON;
135 if (mult < 20) mult = 20;
138 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
140 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
142 r_ptr->r_flags3 |= RF3_DEMON;
144 if (mult < 30) mult = 30;
147 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
149 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
151 r_ptr->r_flags3 |= RF3_ORC;
153 if (mult < 20) mult = 20;
156 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
158 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
160 r_ptr->r_flags3 |= RF3_ORC;
162 if (mult < 30) mult = 30;
165 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
167 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
169 r_ptr->r_flags3 |= RF3_TROLL;
172 if (mult < 20) mult = 20;
175 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
177 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
179 r_ptr->r_flags3 |= RF3_TROLL;
181 if (mult < 30) mult = 30;
184 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
186 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
188 r_ptr->r_flags3 |= RF3_GIANT;
190 if (mult < 20) mult = 20;
193 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
195 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
197 r_ptr->r_flags3 |= RF3_GIANT;
199 if (mult < 30) mult = 30;
202 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
204 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
206 r_ptr->r_flags3 |= RF3_DRAGON;
208 if (mult < 20) mult = 20;
211 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
213 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
215 r_ptr->r_flags3 |= RF3_DRAGON;
217 if (mult < 30) mult = 30;
218 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
219 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
223 if (have_flag(flgs, TR_BRAND_ACID))
225 /* Notice immunity */
226 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
228 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
230 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
235 if (mult < 17) mult = 17;
239 if (have_flag(flgs, TR_BRAND_ELEC))
241 /* Notice immunity */
242 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
244 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
246 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
251 if (mult < 17) mult = 17;
255 if (have_flag(flgs, TR_BRAND_FIRE))
257 /* Notice immunity */
258 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
260 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
262 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
265 /* Otherwise, take the damage */
268 if (r_ptr->flags3 & RF3_HURT_FIRE)
270 if (mult < 25) mult = 25;
271 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
273 r_ptr->r_flags3 |= RF3_HURT_FIRE;
276 else if (mult < 17) mult = 17;
280 if (have_flag(flgs, TR_BRAND_COLD))
282 /* Notice immunity */
283 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
285 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
287 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
290 /* Otherwise, take the damage */
293 if (r_ptr->flags3 & RF3_HURT_COLD)
295 if (mult < 25) mult = 25;
296 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
298 r_ptr->r_flags3 |= RF3_HURT_COLD;
301 else if (mult < 17) mult = 17;
305 if (have_flag(flgs, TR_BRAND_POIS))
307 /* Notice immunity */
308 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
310 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
312 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
315 /* Otherwise, take the damage */
318 if (mult < 17) mult = 17;
322 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
324 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
325 sniper_ptr->redraw |= (PR_MANA);
333 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
335 /* Return the total damage */
336 return (tdam * mult / 10);
342 * Fire an object from the pack or floor.
343 * @param item 射撃するオブジェクトの所持ID
344 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
348 * You may only fire items that "match" your missile launcher.
349 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
350 * See "calc_bonuses()" for more calculations and such.
351 * Note that "firing" a missile is MUCH better than "throwing" it.
352 * Note: "unseen" monsters are very hard to hit.
353 * Objects are more likely to break if they "attempt" to hit a monster.
354 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
355 * The "extra shot" code works by decreasing the amount of energy
356 * required to make each shot, spreading the shots out over time.
357 * Note that when firing missiles, the launcher multiplier is applied
358 * after all the bonuses are added in, making multipliers very useful.
359 * Note that Bows of "Extra Might" get extra range and an extra bonus
360 * for the damage multiplier.
361 * Note that Bows of "Extra Shots" give an extra shot.
364 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
368 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
369 int tdam_base, tdis, thits, tmul;
371 int cur_dis, visible;
379 bool hit_body = FALSE;
381 GAME_TEXT o_name[MAX_NLEN];
383 u16b path_g[512]; /* For calcuration of path length */
385 int msec = delay_factor * delay_factor * delay_factor;
388 bool stick_to = FALSE;
390 /* Access the item (if in the pack) */
393 o_ptr = &shooter_ptr->inventory_list[item];
397 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
400 /* Sniper - Cannot shot a single arrow twice */
401 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
403 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
405 /* Use the proper number of shots */
406 thits = shooter_ptr->num_fire;
408 /* Use a base distance */
411 /* Base damage from thrown object plus launcher bonus */
412 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
414 /* Actually "fire" the object */
415 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
416 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
417 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
419 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
421 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
422 tmul = bow_tmul(j_ptr->sval);
424 /* Get extra "power" from "extra might" */
425 if (shooter_ptr->xtra_might) tmul++;
427 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
429 /* Boost the damage */
434 tdis = 13 + tmul / 80;
435 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
437 if (shooter_ptr->concent)
438 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
443 project_length = tdis + 1;
445 /* Get a direction (or cancel) */
446 if (!get_aim_dir(shooter_ptr, &dir))
448 free_turn(shooter_ptr);
450 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
452 /* need not to reset project_length (already did)*/
457 /* Predict the "target" location */
458 tx = shooter_ptr->x + 99 * ddx[dir];
459 ty = shooter_ptr->y + 99 * ddy[dir];
461 /* Check for "target request" */
462 if ((dir == 5) && target_okay(shooter_ptr))
468 /* Get projection path length */
469 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
471 project_length = 0; /* reset to default */
473 /* Don't shoot at my feet */
474 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
476 free_turn(shooter_ptr);
478 /* project_length is already reset to 0 */
484 /* Take a (partial) turn */
485 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
486 shooter_ptr->is_fired = TRUE;
488 /* Sniper - Difficult to shot twice at 1 turn */
489 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
491 /* Sniper - Repeat shooting when double shots */
492 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
495 /* Start at the player */
499 object_copy(q_ptr, o_ptr);
504 vary_item(shooter_ptr, item, -1);
507 handle_stuff(shooter_ptr);
512 /* The shot does not hit yet */
515 /* Travel until stopped */
516 for (cur_dis = 0; cur_dis <= tdis; )
520 /* Hack -- Stop at the target */
521 if ((y == ty) && (x == tx)) break;
523 /* Calculate the new location (see "project()") */
526 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
529 if (snipe_type == SP_KILL_WALL)
531 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
533 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
535 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
536 /* Forget the wall */
537 g_ptr->info &= ~(CAVE_MARK);
538 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
540 /* Destroy the wall */
541 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
548 /* Stopped by walls/doors */
549 if (!cave_have_flag_bold(shooter_ptr->current_floor_ptr, ny, nx, FF_PROJECT) && !shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx) break;
551 /* Advance the distance */
555 if (snipe_type == SP_LITE)
557 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
558 note_spot(shooter_ptr, ny, nx);
559 lite_spot(shooter_ptr, ny, nx);
562 /* The player can see the (on screen) missile */
563 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
565 char c = object_char(q_ptr);
566 byte a = object_attr(q_ptr);
568 /* Draw, Hilite, Fresh, Pause, Erase */
569 print_rel(shooter_ptr, c, a, ny, nx);
570 move_cursor_relative(ny, nx);
572 Term_xtra(TERM_XTRA_DELAY, msec);
573 lite_spot(shooter_ptr, ny, nx);
577 /* The player cannot see the missile */
580 /* Pause anyway, for consistancy */
581 Term_xtra(TERM_XTRA_DELAY, msec);
585 if (snipe_type == SP_KILL_TRAP)
587 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
588 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
592 if (snipe_type == SP_EVILNESS)
594 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
595 note_spot(shooter_ptr, ny, nx);
596 lite_spot(shooter_ptr, ny, nx);
602 /* Save the new location */
606 /* Monster here, Try to hit it */
607 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
609 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
611 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
612 monster_race *r_ptr = &r_info[m_ptr->r_idx];
614 /* Check the visibility */
617 /* Note the collision */
620 if (MON_CSLEEP(m_ptr))
622 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
623 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
626 if ((r_ptr->level + 10) > shooter_ptr->lev)
628 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
629 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
632 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
633 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
634 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
635 else if (shooter_ptr->lev > 34) amount = 2;
636 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
637 shooter_ptr->update |= (PU_BONUS);
641 if (shooter_ptr->riding)
643 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
644 && ((shooter_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200 < r_info[shooter_ptr->current_floor_ptr->m_list[shooter_ptr->riding].r_idx].level)
647 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
648 shooter_ptr->update |= (PU_BONUS);
652 /* Did we hit it (penalize range) */
653 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
656 int tdam = tdam_base;
658 /* Get extra damage from concentration */
659 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
661 /* Handle unseen monster */
664 /* Invisible monster */
665 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
668 /* Handle visible monster */
671 GAME_TEXT m_name[MAX_NLEN];
673 /* Get "the monster" or "it" */
674 monster_desc(shooter_ptr, m_name, m_ptr, 0);
676 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
680 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
681 health_track(shooter_ptr, c_mon_ptr->m_idx);
685 if (snipe_type == SP_NEEDLE)
687 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
688 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
690 GAME_TEXT m_name[MAX_NLEN];
692 /* Get "the monster" or "it" */
693 monster_desc(shooter_ptr, m_name, m_ptr, 0);
695 tdam = m_ptr->hp + 1;
696 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
702 /* Apply special damage */
703 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
704 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
706 /* No negative damage */
707 if (tdam < 0) tdam = 0;
709 /* Modify the damage */
710 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
713 msg_format_wizard(CHEAT_MONSTER,
714 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
715 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
718 if (snipe_type == SP_EXPLODE)
720 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
722 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
723 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
728 if (snipe_type == SP_HOLYNESS)
730 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
731 note_spot(shooter_ptr, ny, nx);
732 lite_spot(shooter_ptr, ny, nx);
735 /* Hit the monster, check for death */
736 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
745 if (object_is_fixed_artifact(q_ptr) &&
746 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
748 GAME_TEXT m_name[MAX_NLEN];
750 monster_desc(shooter_ptr, m_name, m_ptr, 0);
753 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
756 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
758 /* Anger the monster */
759 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
761 if (fear && m_ptr->ml)
763 GAME_TEXT m_name[MAX_NLEN];
765 monster_desc(shooter_ptr, m_name, m_ptr, 0);
766 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
769 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
772 if (snipe_type == SP_RUSH)
774 int n = randint1(5) + 3;
775 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
777 for (; cur_dis <= tdis; )
784 /* Calculate the new location (see "project()") */
785 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
787 /* Stopped by wilderness boundary */
788 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
790 /* Stopped by walls/doors */
791 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
793 /* Stopped by monsters */
794 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
796 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
797 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
802 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
804 lite_spot(shooter_ptr, ny, nx);
805 lite_spot(shooter_ptr, oy, ox);
808 Term_xtra(TERM_XTRA_DELAY, msec);
820 if (snipe_type == SP_PIERCE)
822 if (shooter_ptr->concent < 1) break;
823 shooter_ptr->concent--;
832 /* Chance of breakage (during attacks) */
833 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
837 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
838 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
839 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
843 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
844 if (object_is_fixed_artifact(q_ptr))
846 a_info[j_ptr->name1].cur_num = 0;
851 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
852 object_copy(o_ptr, q_ptr);
855 o_ptr->marked &= OM_TOUCHED;
857 /* Forget location */
858 o_ptr->iy = o_ptr->ix = 0;
860 /* Memorize monster */
861 o_ptr->held_m_idx = m_idx;
864 o_ptr->next_o_idx = m_ptr->hold_o_idx;
867 m_ptr->hold_o_idx = o_idx;
869 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
871 /* Drop (or break) near that location */
872 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
876 /* Drop (or break) near that location */
877 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
880 /* Sniper - Repeat shooting when double shots */
883 /* Sniper - Loose his/her concentration after any shot */
884 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
889 * @brief プレイヤーからモンスターへの射撃命中判定 /
890 * Determine if the player "hits" a monster (normal combat).
891 * @param chance 基本命中値
892 * @param m_ptr モンスターの構造体参照ポインタ
893 * @param vis 目標を視界に捕らえているならばTRUEを指定
894 * @param o_name メッセージ表示時のモンスター名
895 * @return 命中と判定された場合TRUEを返す
896 * @note Always miss 5%, always hit 5%, otherwise random.
898 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
902 monster_race *r_ptr = &r_info[m_ptr->r_idx];
904 /* Percentile dice */
907 /* Snipers with high-concentration reduce instant miss percentage.*/
908 k += shooter_ptr->concent;
910 /* Hack -- Instant miss or hit */
911 if (k <= 5) return FALSE;
912 if (k > 95) return TRUE;
914 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
915 if (one_in_(20)) return FALSE;
918 if (chance <= 0) return FALSE;
921 if (shooter_ptr->concent)
923 ac *= (8 - shooter_ptr->concent);
927 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
929 /* Invisible monsters are harder to hit */
930 if (!vis) chance = (chance + 1) / 2;
932 /* Power competes against armor */
933 if (randint0(chance) < (ac * 3 / 4))
935 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
937 GAME_TEXT m_name[MAX_NLEN];
938 monster_desc(shooter_ptr, m_name, m_ptr, 0);
939 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
952 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
953 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
954 * @param weight 矢弾の重量
955 * @param plus_ammo 矢弾の命中修正
956 * @param plus_bow 弓の命中修正
957 * @param dam 現在算出中のダメージ値
958 * @return クリティカル修正が入ったダメージ値
960 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
963 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
965 /* Extract "shot" power */
966 i = shooter_ptr->to_h_b + plus_ammo;
968 if (shooter_ptr->tval_ammo == TV_BOLT)
969 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
971 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
974 /* Snipers can shot more critically with crossbows */
975 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
976 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
978 /* Good bow makes more critical */
979 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
982 if (randint1(10000) <= i)
984 k = weight * randint1(500);
988 msg_print(_("手ごたえがあった!", "It was a good hit!"));
993 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
998 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1010 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1011 * @param sval 射撃武器のアイテム副分類ID
1012 * @return 消費する基本エネルギー
1014 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1016 ENERGY energy = 10000;
1018 /* Analyze the launcher */
1021 /* Sling and ammo */
1028 /* Short Bow and Arrow */
1035 /* Long Bow and Arrow */
1042 /* Bow of irresponsiblity and Arrow */
1049 /* Light Crossbow and Bolt */
1056 /* Heavy Crossbow and Bolt */
1071 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1075 /* Analyze the launcher */
1078 /* Sling and ammo */
1085 /* Short Bow and Arrow */
1092 /* Long Bow and Arrow */
1099 /* Bow of irresponsiblity and Arrow */
1106 /* Light Crossbow and Bolt */
1113 /* Heavy Crossbow and Bolt */
1126 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1127 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1128 * @param plus_ammo 矢弾のダメージ修正
1129 * @param plus_bow 弓のダメージ修正
1131 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1133 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1136 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1138 /* Extract "shot" power */
1139 i = shooter_ptr->to_h_b + plus_ammo;
1141 if (shooter_ptr->tval_ammo == TV_BOLT)
1142 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1144 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1146 /* Snipers can shot more critically with crossbows */
1147 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1148 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1150 /* Good bow makes more critical */
1151 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1159 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1160 * @param weight 武器の重量
1161 * @param plus_ammo 矢弾のダメージ修正
1162 * @param plus_bow 弓のダメージ修正
1163 * @param dam 基本ダメージ量
1166 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1170 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1175 crit = MIN(500, 900 / weight);
1176 num += dam * 3 / 2 * crit;
1179 crit = MIN(500, 1350 / weight);
1181 num += dam * 2 * crit;
1187 num += dam * 3 * crit;
1193 num += (10000 - i) * dam;
1200 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1201 * @param shooter_ptr プレーヤーへの参照ポインタ
1202 * @param weight 武器の重量
1203 * @param plus 武器のダメージ修正
1205 * @param meichuu 命中値
1206 * @param dokubari 毒針処理か否か
1209 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1212 if (dokubari) return dam;
1214 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1220 if (k < 400) num += (2 * dam + 5) * (400 - k);
1221 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1222 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1223 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1224 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1227 if (shooter_ptr->pclass == CLASS_NINJA)
1230 num += (4444 - i) * dam;
1236 num += (5000 - i) * dam;