1 #include "combat/shoot.h"
2 #include "art-definition/art-bow-types.h"
3 #include "mind/mind-sniper.h"
4 #include "core/stuff-handler.h"
5 #include "effect/effect-characteristics.h"
6 #include "effect/spells-effect-util.h"
7 #include "floor/floor-object.h"
8 #include "game-option/special-options.h"
10 #include "inventory/inventory-object.h"
11 #include "io/targeting.h"
12 #include "main/sound-definitions-table.h"
13 #include "main/sound-of-music.h"
14 #include "mind/snipe-types.h"
15 #include "monster-race/race-flags-resistance.h"
16 #include "monster-race/race-flags1.h"
17 #include "monster-race/race-flags2.h"
18 #include "monster-race/race-flags3.h"
19 #include "monster-race/race-flags7.h"
20 #include "monster-race/race-indice-types.h"
21 #include "monster/monster-describer.h"
22 #include "monster-floor/monster-death.h"
23 #include "monster/monster-status.h"
24 #include "monster/monster-info.h"
25 #include "monster-floor/monster-move.h"
26 #include "monster/monster-update.h"
27 #include "mspell/monster-spell.h"
28 #include "object-enchant/artifact.h"
29 #include "object-enchant/tr-types.h"
30 #include "object/object-broken.h"
31 #include "object/object-flags.h"
32 #include "object/object-flavor.h"
33 #include "object/object-generator.h"
34 #include "object/object-hook.h"
35 #include "object/object-kind.h"
36 #include "object/object-mark-types.h"
37 #include "object/object-info.h"
38 #include "player/avatar.h"
39 #include "player/player-class.h"
40 #include "player/player-personalities-types.h"
41 #include "player/player-skill.h"
42 #include "player/player-status.h"
43 #include "spell/process-effect.h"
44 #include "spell/spell-types.h"
45 #include "sv-definition/sv-bow-types.h"
46 #include "view/display-main-window.h"
47 #include "view/display-messages.h"
48 #include "world/world-object.h"
51 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
52 * Determines the odds of an object breaking when thrown at a monster
53 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
54 * @param tdam 計算途中のダメージ量
55 * @param m_ptr 目標モンスターの構造体参照ポインタ
56 * @return スレイ倍率をかけたダメージ量
58 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)
62 monster_race *r_ptr = &r_info[m_ptr->r_idx];
64 BIT_FLAGS flgs[TR_FLAG_SIZE];
65 object_flags(o_ptr, flgs);
67 /* Some "weapons" and "ammo" do extra damage */
74 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
76 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
78 r_ptr->r_flags3 |= RF3_ANIMAL;
80 if (mult < 17) mult = 17;
83 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
85 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
87 r_ptr->r_flags3 |= RF3_ANIMAL;
89 if (mult < 27) mult = 27;
92 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
94 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
96 r_ptr->r_flags3 |= RF3_EVIL;
98 if (mult < 15) mult = 15;
101 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
103 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
105 r_ptr->r_flags3 |= RF3_EVIL;
107 if (mult < 25) mult = 25;
110 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
112 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
114 r_ptr->r_flags2 |= RF2_HUMAN;
116 if (mult < 17) mult = 17;
119 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
121 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
123 r_ptr->r_flags2 |= RF2_HUMAN;
125 if (mult < 27) mult = 27;
128 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
130 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
132 r_ptr->r_flags3 |= RF3_UNDEAD;
134 if (mult < 20) mult = 20;
137 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
139 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
141 r_ptr->r_flags3 |= RF3_UNDEAD;
143 if (mult < 30) mult = 30;
146 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
148 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
150 r_ptr->r_flags3 |= RF3_DEMON;
152 if (mult < 20) mult = 20;
155 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
157 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
159 r_ptr->r_flags3 |= RF3_DEMON;
161 if (mult < 30) mult = 30;
164 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
166 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
168 r_ptr->r_flags3 |= RF3_ORC;
170 if (mult < 20) mult = 20;
173 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
175 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
177 r_ptr->r_flags3 |= RF3_ORC;
179 if (mult < 30) mult = 30;
182 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
184 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
186 r_ptr->r_flags3 |= RF3_TROLL;
189 if (mult < 20) mult = 20;
192 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
194 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
196 r_ptr->r_flags3 |= RF3_TROLL;
198 if (mult < 30) mult = 30;
201 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
203 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
205 r_ptr->r_flags3 |= RF3_GIANT;
207 if (mult < 20) mult = 20;
210 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
212 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
214 r_ptr->r_flags3 |= RF3_GIANT;
216 if (mult < 30) mult = 30;
219 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
221 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
223 r_ptr->r_flags3 |= RF3_DRAGON;
225 if (mult < 20) mult = 20;
228 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
230 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
232 r_ptr->r_flags3 |= RF3_DRAGON;
234 if (mult < 30) mult = 30;
235 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
236 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
240 if (have_flag(flgs, TR_BRAND_ACID))
242 /* Notice immunity */
243 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
245 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
247 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
252 if (mult < 17) mult = 17;
256 if (have_flag(flgs, TR_BRAND_ELEC))
258 /* Notice immunity */
259 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
261 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
263 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
268 if (mult < 17) mult = 17;
272 if (have_flag(flgs, TR_BRAND_FIRE))
274 /* Notice immunity */
275 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
277 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
279 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
282 /* Otherwise, take the damage */
285 if (r_ptr->flags3 & RF3_HURT_FIRE)
287 if (mult < 25) mult = 25;
288 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
290 r_ptr->r_flags3 |= RF3_HURT_FIRE;
293 else if (mult < 17) mult = 17;
297 if (have_flag(flgs, TR_BRAND_COLD))
299 /* Notice immunity */
300 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
302 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
304 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
307 /* Otherwise, take the damage */
310 if (r_ptr->flags3 & RF3_HURT_COLD)
312 if (mult < 25) mult = 25;
313 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
315 r_ptr->r_flags3 |= RF3_HURT_COLD;
318 else if (mult < 17) mult = 17;
322 if (have_flag(flgs, TR_BRAND_POIS))
324 /* Notice immunity */
325 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
327 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
329 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
332 /* Otherwise, take the damage */
335 if (mult < 17) mult = 17;
339 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
341 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
342 sniper_ptr->redraw |= (PR_MANA);
350 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
352 /* Return the total damage */
353 return (tdam * mult / 10);
359 * Fire an object from the pack or floor.
360 * @param item 射撃するオブジェクトの所持ID
361 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
365 * You may only fire items that "match" your missile launcher.
366 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
367 * See "calc_bonuses()" for more calculations and such.
368 * Note that "firing" a missile is MUCH better than "throwing" it.
369 * Note: "unseen" monsters are very hard to hit.
370 * Objects are more likely to break if they "attempt" to hit a monster.
371 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
372 * The "extra shot" code works by decreasing the amount of energy
373 * required to make each shot, spreading the shots out over time.
374 * Note that when firing missiles, the launcher multiplier is applied
375 * after all the bonuses are added in, making multipliers very useful.
376 * Note that Bows of "Extra Might" get extra range and an extra bonus
377 * for the damage multiplier.
378 * Note that Bows of "Extra Shots" give an extra shot.
381 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
385 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
386 int tdam_base, tdis, thits, tmul;
388 int cur_dis, visible;
396 bool hit_body = FALSE;
398 GAME_TEXT o_name[MAX_NLEN];
400 u16b path_g[512]; /* For calcuration of path length */
402 int msec = delay_factor * delay_factor * delay_factor;
405 bool stick_to = FALSE;
407 /* Access the item (if in the pack) */
410 o_ptr = &shooter_ptr->inventory_list[item];
414 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
417 /* Sniper - Cannot shot a single arrow twice */
418 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
420 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
422 /* Use the proper number of shots */
423 thits = shooter_ptr->num_fire;
425 /* Use a base distance */
428 /* Base damage from thrown object plus launcher bonus */
429 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
431 /* Actually "fire" the object */
432 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
433 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
434 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
436 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
438 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
439 tmul = bow_tmul(j_ptr->sval);
441 /* Get extra "power" from "extra might" */
442 if (shooter_ptr->xtra_might) tmul++;
444 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
446 /* Boost the damage */
451 tdis = 13 + tmul / 80;
452 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
454 if (shooter_ptr->concent)
455 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
460 project_length = tdis + 1;
462 /* Get a direction (or cancel) */
463 if (!get_aim_dir(shooter_ptr, &dir))
465 free_turn(shooter_ptr);
467 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
469 /* need not to reset project_length (already did)*/
474 /* Predict the "target" location */
475 tx = shooter_ptr->x + 99 * ddx[dir];
476 ty = shooter_ptr->y + 99 * ddy[dir];
478 /* Check for "target request" */
479 if ((dir == 5) && target_okay(shooter_ptr))
485 /* Get projection path length */
486 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
488 project_length = 0; /* reset to default */
490 /* Don't shoot at my feet */
491 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
493 free_turn(shooter_ptr);
495 /* project_length is already reset to 0 */
501 /* Take a (partial) turn */
502 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
503 shooter_ptr->is_fired = TRUE;
505 /* Sniper - Difficult to shot twice at 1 turn */
506 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
508 /* Sniper - Repeat shooting when double shots */
509 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
512 /* Start at the player */
516 object_copy(q_ptr, o_ptr);
521 vary_item(shooter_ptr, item, -1);
524 handle_stuff(shooter_ptr);
529 /* The shot does not hit yet */
532 /* Travel until stopped */
533 for (cur_dis = 0; cur_dis <= tdis; )
537 /* Hack -- Stop at the target */
538 if ((y == ty) && (x == tx)) break;
540 /* Calculate the new location (see "project()") */
543 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
546 if (snipe_type == SP_KILL_WALL)
548 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
550 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
552 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
553 /* Forget the wall */
554 g_ptr->info &= ~(CAVE_MARK);
555 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
557 /* Destroy the wall */
558 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
565 /* Stopped by walls/doors */
566 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;
568 /* Advance the distance */
572 if (snipe_type == SP_LITE)
574 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
575 note_spot(shooter_ptr, ny, nx);
576 lite_spot(shooter_ptr, ny, nx);
579 /* The player can see the (on screen) missile */
580 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
582 char c = object_char(q_ptr);
583 byte a = object_attr(q_ptr);
585 /* Draw, Hilite, Fresh, Pause, Erase */
586 print_rel(shooter_ptr, c, a, ny, nx);
587 move_cursor_relative(ny, nx);
589 Term_xtra(TERM_XTRA_DELAY, msec);
590 lite_spot(shooter_ptr, ny, nx);
594 /* The player cannot see the missile */
597 /* Pause anyway, for consistancy */
598 Term_xtra(TERM_XTRA_DELAY, msec);
602 if (snipe_type == SP_KILL_TRAP)
604 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
605 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
609 if (snipe_type == SP_EVILNESS)
611 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
612 note_spot(shooter_ptr, ny, nx);
613 lite_spot(shooter_ptr, ny, nx);
619 /* Save the new location */
623 /* Monster here, Try to hit it */
624 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
626 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
628 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
629 monster_race *r_ptr = &r_info[m_ptr->r_idx];
631 /* Check the visibility */
634 /* Note the collision */
637 if (monster_csleep_remaining(m_ptr))
639 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
640 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
643 if ((r_ptr->level + 10) > shooter_ptr->lev)
645 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
646 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
649 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
650 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
651 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
652 else if (shooter_ptr->lev > 34) amount = 2;
653 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
654 shooter_ptr->update |= (PU_BONUS);
658 if (shooter_ptr->riding)
660 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
661 && ((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)
664 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
665 shooter_ptr->update |= (PU_BONUS);
669 /* Did we hit it (penalize range) */
670 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
673 int tdam = tdam_base;
675 /* Get extra damage from concentration */
676 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
678 /* Handle unseen monster */
681 /* Invisible monster */
682 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
685 /* Handle visible monster */
688 GAME_TEXT m_name[MAX_NLEN];
690 /* Get "the monster" or "it" */
691 monster_desc(shooter_ptr, m_name, m_ptr, 0);
693 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
697 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
698 health_track(shooter_ptr, c_mon_ptr->m_idx);
702 if (snipe_type == SP_NEEDLE)
704 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
705 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
707 GAME_TEXT m_name[MAX_NLEN];
709 /* Get "the monster" or "it" */
710 monster_desc(shooter_ptr, m_name, m_ptr, 0);
712 tdam = m_ptr->hp + 1;
713 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
719 /* Apply special damage */
720 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
721 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
723 /* No negative damage */
724 if (tdam < 0) tdam = 0;
726 /* Modify the damage */
727 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
730 msg_format_wizard(CHEAT_MONSTER,
731 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
732 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
735 if (snipe_type == SP_EXPLODE)
737 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
739 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
740 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
745 if (snipe_type == SP_HOLYNESS)
747 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
748 note_spot(shooter_ptr, ny, nx);
749 lite_spot(shooter_ptr, ny, nx);
752 /* Hit the monster, check for death */
753 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
762 if (object_is_fixed_artifact(q_ptr) &&
763 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
765 GAME_TEXT m_name[MAX_NLEN];
767 monster_desc(shooter_ptr, m_name, m_ptr, 0);
770 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
773 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
775 /* Anger the monster */
776 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
778 if (fear && m_ptr->ml)
780 GAME_TEXT m_name[MAX_NLEN];
782 monster_desc(shooter_ptr, m_name, m_ptr, 0);
783 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
786 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
789 if (snipe_type == SP_RUSH)
791 int n = randint1(5) + 3;
792 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
794 for (; cur_dis <= tdis; )
801 /* Calculate the new location (see "project()") */
802 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
804 /* Stopped by wilderness boundary */
805 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
807 /* Stopped by walls/doors */
808 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
810 /* Stopped by monsters */
811 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
813 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
814 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
819 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
821 lite_spot(shooter_ptr, ny, nx);
822 lite_spot(shooter_ptr, oy, ox);
825 Term_xtra(TERM_XTRA_DELAY, msec);
837 if (snipe_type == SP_PIERCE)
839 if (shooter_ptr->concent < 1) break;
840 shooter_ptr->concent--;
849 /* Chance of breakage (during attacks) */
850 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
854 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
855 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
856 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
860 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
861 if (object_is_fixed_artifact(q_ptr))
863 a_info[j_ptr->name1].cur_num = 0;
868 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
869 object_copy(o_ptr, q_ptr);
872 o_ptr->marked &= OM_TOUCHED;
874 /* Forget location */
875 o_ptr->iy = o_ptr->ix = 0;
877 /* Memorize monster */
878 o_ptr->held_m_idx = m_idx;
881 o_ptr->next_o_idx = m_ptr->hold_o_idx;
884 m_ptr->hold_o_idx = o_idx;
886 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
888 /* Drop (or break) near that location */
889 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
893 /* Drop (or break) near that location */
894 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
897 /* Sniper - Repeat shooting when double shots */
900 /* Sniper - Loose his/her concentration after any shot */
901 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
906 * @brief プレイヤーからモンスターへの射撃命中判定 /
907 * Determine if the player "hits" a monster (normal combat).
908 * @param chance 基本命中値
909 * @param m_ptr モンスターの構造体参照ポインタ
910 * @param vis 目標を視界に捕らえているならばTRUEを指定
911 * @param o_name メッセージ表示時のモンスター名
912 * @return 命中と判定された場合TRUEを返す
913 * @note Always miss 5%, always hit 5%, otherwise random.
915 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
919 monster_race *r_ptr = &r_info[m_ptr->r_idx];
921 /* Percentile dice */
924 /* Snipers with high-concentration reduce instant miss percentage.*/
925 k += shooter_ptr->concent;
927 /* Hack -- Instant miss or hit */
928 if (k <= 5) return FALSE;
929 if (k > 95) return TRUE;
931 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
932 if (one_in_(20)) return FALSE;
935 if (chance <= 0) return FALSE;
938 if (shooter_ptr->concent)
940 ac *= (8 - shooter_ptr->concent);
944 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) ac *= 3;
946 /* Invisible monsters are harder to hit */
947 if (!vis) chance = (chance + 1) / 2;
949 /* Power competes against armor */
950 if (randint0(chance) < (ac * 3 / 4))
952 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
954 GAME_TEXT m_name[MAX_NLEN];
955 monster_desc(shooter_ptr, m_name, m_ptr, 0);
956 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
969 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
970 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
971 * @param weight 矢弾の重量
972 * @param plus_ammo 矢弾の命中修正
973 * @param plus_bow 弓の命中修正
974 * @param dam 現在算出中のダメージ値
975 * @return クリティカル修正が入ったダメージ値
977 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
980 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
982 /* Extract "shot" power */
983 i = shooter_ptr->to_h_b + plus_ammo;
985 if (shooter_ptr->tval_ammo == TV_BOLT)
986 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
988 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
991 /* Snipers can shot more critically with crossbows */
992 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
993 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
995 /* Good bow makes more critical */
996 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
999 if (randint1(10000) <= i)
1001 k = weight * randint1(500);
1005 msg_print(_("手ごたえがあった!", "It was a good hit!"));
1010 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1015 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1027 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1028 * @param sval 射撃武器のアイテム副分類ID
1029 * @return 消費する基本エネルギー
1031 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1033 ENERGY energy = 10000;
1035 /* Analyze the launcher */
1038 /* Sling and ammo */
1045 /* Short Bow and Arrow */
1052 /* Long Bow and Arrow */
1059 /* Bow of irresponsiblity and Arrow */
1066 /* Light Crossbow and Bolt */
1073 /* Heavy Crossbow and Bolt */
1088 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1092 /* Analyze the launcher */
1095 /* Sling and ammo */
1102 /* Short Bow and Arrow */
1109 /* Long Bow and Arrow */
1116 /* Bow of irresponsiblity and Arrow */
1123 /* Light Crossbow and Bolt */
1130 /* Heavy Crossbow and Bolt */
1143 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1144 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1145 * @param plus_ammo 矢弾のダメージ修正
1146 * @param plus_bow 弓のダメージ修正
1148 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1150 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1153 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1155 /* Extract "shot" power */
1156 i = shooter_ptr->to_h_b + plus_ammo;
1158 if (shooter_ptr->tval_ammo == TV_BOLT)
1159 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1161 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1163 /* Snipers can shot more critically with crossbows */
1164 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1165 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1167 /* Good bow makes more critical */
1168 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1176 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1177 * @param weight 武器の重量
1178 * @param plus_ammo 矢弾のダメージ修正
1179 * @param plus_bow 弓のダメージ修正
1180 * @param dam 基本ダメージ量
1183 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1187 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1192 crit = MIN(500, 900 / weight);
1193 num += dam * 3 / 2 * crit;
1196 crit = MIN(500, 1350 / weight);
1198 num += dam * 2 * crit;
1204 num += dam * 3 * crit;
1210 num += (10000 - i) * dam;
1217 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1218 * @param shooter_ptr プレーヤーへの参照ポインタ
1219 * @param weight 武器の重量
1220 * @param plus 武器のダメージ修正
1222 * @param meichuu 命中値
1223 * @param dokubari 毒針処理か否か
1226 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1229 if (dokubari) return dam;
1231 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1237 if (k < 400) num += (2 * dam + 5) * (400 - k);
1238 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1239 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1240 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1241 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1244 if (shooter_ptr->pclass == CLASS_NINJA)
1247 num += (4444 - i) * dam;
1253 num += (5000 - i) * dam;