1 #include "combat/shoot.h"
2 #include "art-definition/art-bow-types.h"
3 #include "combat/snipe.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"
9 #include "inventory/inventory-object.h"
10 #include "io/targeting.h"
11 #include "main/sound-definitions-table.h"
12 #include "monster-race/race-indice-types.h"
13 #include "monster/monster-status.h"
14 #include "monster/monster.h"
15 #include "mspell/monster-spell.h"
16 #include "object-enchant/artifact.h"
17 #include "object-enchant/tr-types.h"
18 #include "object/object-broken.h"
19 #include "object/object-flags.h"
20 #include "object/object-flavor.h"
21 #include "object/object-generator.h"
22 #include "object/object-hook.h"
23 #include "object/object-kind.h"
24 #include "object/object-mark-types.h"
25 #include "object/object-info.h"
26 #include "player/avatar.h"
27 #include "player/player-class.h"
28 #include "player/player-personalities-table.h"
29 #include "player/player-skill.h"
30 #include "player/player-status.h"
31 #include "spell/process-effect.h"
32 #include "spell/spells-type.h"
33 #include "sv-definition/sv-bow-types.h"
34 #include "util/util.h"
35 #include "view/display-main-window.h"
36 #include "world/world-object.h"
39 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
40 * Determines the odds of an object breaking when thrown at a monster
41 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
42 * @param tdam 計算途中のダメージ量
43 * @param m_ptr 目標モンスターの構造体参照ポインタ
44 * @return スレイ倍率をかけたダメージ量
46 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)
50 monster_race *r_ptr = &r_info[m_ptr->r_idx];
52 BIT_FLAGS flgs[TR_FLAG_SIZE];
53 object_flags(o_ptr, flgs);
55 /* Some "weapons" and "ammo" do extra damage */
62 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
64 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
66 r_ptr->r_flags3 |= RF3_ANIMAL;
68 if (mult < 17) mult = 17;
71 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
73 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
75 r_ptr->r_flags3 |= RF3_ANIMAL;
77 if (mult < 27) mult = 27;
80 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
82 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
84 r_ptr->r_flags3 |= RF3_EVIL;
86 if (mult < 15) mult = 15;
89 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
91 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
93 r_ptr->r_flags3 |= RF3_EVIL;
95 if (mult < 25) mult = 25;
98 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
100 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
102 r_ptr->r_flags2 |= RF2_HUMAN;
104 if (mult < 17) mult = 17;
107 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
109 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
111 r_ptr->r_flags2 |= RF2_HUMAN;
113 if (mult < 27) mult = 27;
116 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
118 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
120 r_ptr->r_flags3 |= RF3_UNDEAD;
122 if (mult < 20) mult = 20;
125 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
127 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
129 r_ptr->r_flags3 |= RF3_UNDEAD;
131 if (mult < 30) mult = 30;
134 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
136 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
138 r_ptr->r_flags3 |= RF3_DEMON;
140 if (mult < 20) mult = 20;
143 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
145 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
147 r_ptr->r_flags3 |= RF3_DEMON;
149 if (mult < 30) mult = 30;
152 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
154 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
156 r_ptr->r_flags3 |= RF3_ORC;
158 if (mult < 20) mult = 20;
161 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
163 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
165 r_ptr->r_flags3 |= RF3_ORC;
167 if (mult < 30) mult = 30;
170 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
172 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
174 r_ptr->r_flags3 |= RF3_TROLL;
177 if (mult < 20) mult = 20;
180 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
182 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
184 r_ptr->r_flags3 |= RF3_TROLL;
186 if (mult < 30) mult = 30;
189 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
191 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
193 r_ptr->r_flags3 |= RF3_GIANT;
195 if (mult < 20) mult = 20;
198 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
200 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
202 r_ptr->r_flags3 |= RF3_GIANT;
204 if (mult < 30) mult = 30;
207 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
209 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
211 r_ptr->r_flags3 |= RF3_DRAGON;
213 if (mult < 20) mult = 20;
216 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
218 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
220 r_ptr->r_flags3 |= RF3_DRAGON;
222 if (mult < 30) mult = 30;
223 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
224 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
228 if (have_flag(flgs, TR_BRAND_ACID))
230 /* Notice immunity */
231 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
233 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
235 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
240 if (mult < 17) mult = 17;
244 if (have_flag(flgs, TR_BRAND_ELEC))
246 /* Notice immunity */
247 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
249 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
251 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
256 if (mult < 17) mult = 17;
260 if (have_flag(flgs, TR_BRAND_FIRE))
262 /* Notice immunity */
263 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
265 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
267 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
270 /* Otherwise, take the damage */
273 if (r_ptr->flags3 & RF3_HURT_FIRE)
275 if (mult < 25) mult = 25;
276 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
278 r_ptr->r_flags3 |= RF3_HURT_FIRE;
281 else if (mult < 17) mult = 17;
285 if (have_flag(flgs, TR_BRAND_COLD))
287 /* Notice immunity */
288 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
290 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
292 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
295 /* Otherwise, take the damage */
298 if (r_ptr->flags3 & RF3_HURT_COLD)
300 if (mult < 25) mult = 25;
301 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
303 r_ptr->r_flags3 |= RF3_HURT_COLD;
306 else if (mult < 17) mult = 17;
310 if (have_flag(flgs, TR_BRAND_POIS))
312 /* Notice immunity */
313 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
315 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
317 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
320 /* Otherwise, take the damage */
323 if (mult < 17) mult = 17;
327 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
329 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
330 sniper_ptr->redraw |= (PR_MANA);
338 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
340 /* Return the total damage */
341 return (tdam * mult / 10);
347 * Fire an object from the pack or floor.
348 * @param item 射撃するオブジェクトの所持ID
349 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
353 * You may only fire items that "match" your missile launcher.
354 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
355 * See "calc_bonuses()" for more calculations and such.
356 * Note that "firing" a missile is MUCH better than "throwing" it.
357 * Note: "unseen" monsters are very hard to hit.
358 * Objects are more likely to break if they "attempt" to hit a monster.
359 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
360 * The "extra shot" code works by decreasing the amount of energy
361 * required to make each shot, spreading the shots out over time.
362 * Note that when firing missiles, the launcher multiplier is applied
363 * after all the bonuses are added in, making multipliers very useful.
364 * Note that Bows of "Extra Might" get extra range and an extra bonus
365 * for the damage multiplier.
366 * Note that Bows of "Extra Shots" give an extra shot.
369 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
373 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
374 int tdam_base, tdis, thits, tmul;
376 int cur_dis, visible;
384 bool hit_body = FALSE;
386 GAME_TEXT o_name[MAX_NLEN];
388 u16b path_g[512]; /* For calcuration of path length */
390 int msec = delay_factor * delay_factor * delay_factor;
393 bool stick_to = FALSE;
395 /* Access the item (if in the pack) */
398 o_ptr = &shooter_ptr->inventory_list[item];
402 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
405 /* Sniper - Cannot shot a single arrow twice */
406 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
408 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
410 /* Use the proper number of shots */
411 thits = shooter_ptr->num_fire;
413 /* Use a base distance */
416 /* Base damage from thrown object plus launcher bonus */
417 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
419 /* Actually "fire" the object */
420 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
421 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
422 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
424 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
426 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
427 tmul = bow_tmul(j_ptr->sval);
429 /* Get extra "power" from "extra might" */
430 if (shooter_ptr->xtra_might) tmul++;
432 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
434 /* Boost the damage */
439 tdis = 13 + tmul / 80;
440 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
442 if (shooter_ptr->concent)
443 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
448 project_length = tdis + 1;
450 /* Get a direction (or cancel) */
451 if (!get_aim_dir(shooter_ptr, &dir))
453 free_turn(shooter_ptr);
455 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
457 /* need not to reset project_length (already did)*/
462 /* Predict the "target" location */
463 tx = shooter_ptr->x + 99 * ddx[dir];
464 ty = shooter_ptr->y + 99 * ddy[dir];
466 /* Check for "target request" */
467 if ((dir == 5) && target_okay(shooter_ptr))
473 /* Get projection path length */
474 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
476 project_length = 0; /* reset to default */
478 /* Don't shoot at my feet */
479 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
481 free_turn(shooter_ptr);
483 /* project_length is already reset to 0 */
489 /* Take a (partial) turn */
490 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
491 shooter_ptr->is_fired = TRUE;
493 /* Sniper - Difficult to shot twice at 1 turn */
494 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
496 /* Sniper - Repeat shooting when double shots */
497 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
500 /* Start at the player */
504 object_copy(q_ptr, o_ptr);
509 vary_item(shooter_ptr, item, -1);
512 handle_stuff(shooter_ptr);
517 /* The shot does not hit yet */
520 /* Travel until stopped */
521 for (cur_dis = 0; cur_dis <= tdis; )
525 /* Hack -- Stop at the target */
526 if ((y == ty) && (x == tx)) break;
528 /* Calculate the new location (see "project()") */
531 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
534 if (snipe_type == SP_KILL_WALL)
536 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
538 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
540 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
541 /* Forget the wall */
542 g_ptr->info &= ~(CAVE_MARK);
543 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
545 /* Destroy the wall */
546 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
553 /* Stopped by walls/doors */
554 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;
556 /* Advance the distance */
560 if (snipe_type == SP_LITE)
562 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
563 note_spot(shooter_ptr, ny, nx);
564 lite_spot(shooter_ptr, ny, nx);
567 /* The player can see the (on screen) missile */
568 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
570 char c = object_char(q_ptr);
571 byte a = object_attr(q_ptr);
573 /* Draw, Hilite, Fresh, Pause, Erase */
574 print_rel(shooter_ptr, c, a, ny, nx);
575 move_cursor_relative(ny, nx);
577 Term_xtra(TERM_XTRA_DELAY, msec);
578 lite_spot(shooter_ptr, ny, nx);
582 /* The player cannot see the missile */
585 /* Pause anyway, for consistancy */
586 Term_xtra(TERM_XTRA_DELAY, msec);
590 if (snipe_type == SP_KILL_TRAP)
592 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
593 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
597 if (snipe_type == SP_EVILNESS)
599 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
600 note_spot(shooter_ptr, ny, nx);
601 lite_spot(shooter_ptr, ny, nx);
607 /* Save the new location */
611 /* Monster here, Try to hit it */
612 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
614 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
616 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
617 monster_race *r_ptr = &r_info[m_ptr->r_idx];
619 /* Check the visibility */
622 /* Note the collision */
625 if (MON_CSLEEP(m_ptr))
627 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
628 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
631 if ((r_ptr->level + 10) > shooter_ptr->lev)
633 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
634 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
637 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
638 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
639 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
640 else if (shooter_ptr->lev > 34) amount = 2;
641 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
642 shooter_ptr->update |= (PU_BONUS);
646 if (shooter_ptr->riding)
648 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
649 && ((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)
652 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
653 shooter_ptr->update |= (PU_BONUS);
657 /* Did we hit it (penalize range) */
658 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
661 int tdam = tdam_base;
663 /* Get extra damage from concentration */
664 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
666 /* Handle unseen monster */
669 /* Invisible monster */
670 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
673 /* Handle visible monster */
676 GAME_TEXT m_name[MAX_NLEN];
678 /* Get "the monster" or "it" */
679 monster_desc(shooter_ptr, m_name, m_ptr, 0);
681 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
685 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
686 health_track(shooter_ptr, c_mon_ptr->m_idx);
690 if (snipe_type == SP_NEEDLE)
692 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
693 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
695 GAME_TEXT m_name[MAX_NLEN];
697 /* Get "the monster" or "it" */
698 monster_desc(shooter_ptr, m_name, m_ptr, 0);
700 tdam = m_ptr->hp + 1;
701 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
707 /* Apply special damage */
708 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
709 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
711 /* No negative damage */
712 if (tdam < 0) tdam = 0;
714 /* Modify the damage */
715 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
718 msg_format_wizard(CHEAT_MONSTER,
719 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
720 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
723 if (snipe_type == SP_EXPLODE)
725 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
727 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
728 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
733 if (snipe_type == SP_HOLYNESS)
735 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
736 note_spot(shooter_ptr, ny, nx);
737 lite_spot(shooter_ptr, ny, nx);
740 /* Hit the monster, check for death */
741 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
750 if (object_is_fixed_artifact(q_ptr) &&
751 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
753 GAME_TEXT m_name[MAX_NLEN];
755 monster_desc(shooter_ptr, m_name, m_ptr, 0);
758 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
761 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
763 /* Anger the monster */
764 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
766 if (fear && m_ptr->ml)
768 GAME_TEXT m_name[MAX_NLEN];
770 monster_desc(shooter_ptr, m_name, m_ptr, 0);
771 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
774 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
777 if (snipe_type == SP_RUSH)
779 int n = randint1(5) + 3;
780 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
782 for (; cur_dis <= tdis; )
789 /* Calculate the new location (see "project()") */
790 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
792 /* Stopped by wilderness boundary */
793 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
795 /* Stopped by walls/doors */
796 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
798 /* Stopped by monsters */
799 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
801 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
802 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
807 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
809 lite_spot(shooter_ptr, ny, nx);
810 lite_spot(shooter_ptr, oy, ox);
813 Term_xtra(TERM_XTRA_DELAY, msec);
825 if (snipe_type == SP_PIERCE)
827 if (shooter_ptr->concent < 1) break;
828 shooter_ptr->concent--;
837 /* Chance of breakage (during attacks) */
838 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
842 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
843 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
844 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
848 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
849 if (object_is_fixed_artifact(q_ptr))
851 a_info[j_ptr->name1].cur_num = 0;
856 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
857 object_copy(o_ptr, q_ptr);
860 o_ptr->marked &= OM_TOUCHED;
862 /* Forget location */
863 o_ptr->iy = o_ptr->ix = 0;
865 /* Memorize monster */
866 o_ptr->held_m_idx = m_idx;
869 o_ptr->next_o_idx = m_ptr->hold_o_idx;
872 m_ptr->hold_o_idx = o_idx;
874 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
876 /* Drop (or break) near that location */
877 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
881 /* Drop (or break) near that location */
882 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
885 /* Sniper - Repeat shooting when double shots */
888 /* Sniper - Loose his/her concentration after any shot */
889 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
894 * @brief プレイヤーからモンスターへの射撃命中判定 /
895 * Determine if the player "hits" a monster (normal combat).
896 * @param chance 基本命中値
897 * @param m_ptr モンスターの構造体参照ポインタ
898 * @param vis 目標を視界に捕らえているならばTRUEを指定
899 * @param o_name メッセージ表示時のモンスター名
900 * @return 命中と判定された場合TRUEを返す
901 * @note Always miss 5%, always hit 5%, otherwise random.
903 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
907 monster_race *r_ptr = &r_info[m_ptr->r_idx];
909 /* Percentile dice */
912 /* Snipers with high-concentration reduce instant miss percentage.*/
913 k += shooter_ptr->concent;
915 /* Hack -- Instant miss or hit */
916 if (k <= 5) return FALSE;
917 if (k > 95) return TRUE;
919 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
920 if (one_in_(20)) return FALSE;
923 if (chance <= 0) return FALSE;
926 if (shooter_ptr->concent)
928 ac *= (8 - shooter_ptr->concent);
932 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
934 /* Invisible monsters are harder to hit */
935 if (!vis) chance = (chance + 1) / 2;
937 /* Power competes against armor */
938 if (randint0(chance) < (ac * 3 / 4))
940 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
942 GAME_TEXT m_name[MAX_NLEN];
943 monster_desc(shooter_ptr, m_name, m_ptr, 0);
944 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
957 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
958 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
959 * @param weight 矢弾の重量
960 * @param plus_ammo 矢弾の命中修正
961 * @param plus_bow 弓の命中修正
962 * @param dam 現在算出中のダメージ値
963 * @return クリティカル修正が入ったダメージ値
965 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
968 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
970 /* Extract "shot" power */
971 i = shooter_ptr->to_h_b + plus_ammo;
973 if (shooter_ptr->tval_ammo == TV_BOLT)
974 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
976 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
979 /* Snipers can shot more critically with crossbows */
980 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
981 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
983 /* Good bow makes more critical */
984 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
987 if (randint1(10000) <= i)
989 k = weight * randint1(500);
993 msg_print(_("手ごたえがあった!", "It was a good hit!"));
998 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1003 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1015 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1016 * @param sval 射撃武器のアイテム副分類ID
1017 * @return 消費する基本エネルギー
1019 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1021 ENERGY energy = 10000;
1023 /* Analyze the launcher */
1026 /* Sling and ammo */
1033 /* Short Bow and Arrow */
1040 /* Long Bow and Arrow */
1047 /* Bow of irresponsiblity and Arrow */
1054 /* Light Crossbow and Bolt */
1061 /* Heavy Crossbow and Bolt */
1076 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1080 /* Analyze the launcher */
1083 /* Sling and ammo */
1090 /* Short Bow and Arrow */
1097 /* Long Bow and Arrow */
1104 /* Bow of irresponsiblity and Arrow */
1111 /* Light Crossbow and Bolt */
1118 /* Heavy Crossbow and Bolt */
1131 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1132 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1133 * @param plus_ammo 矢弾のダメージ修正
1134 * @param plus_bow 弓のダメージ修正
1136 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1138 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1141 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1143 /* Extract "shot" power */
1144 i = shooter_ptr->to_h_b + plus_ammo;
1146 if (shooter_ptr->tval_ammo == TV_BOLT)
1147 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1149 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1151 /* Snipers can shot more critically with crossbows */
1152 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1153 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1155 /* Good bow makes more critical */
1156 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1164 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1165 * @param weight 武器の重量
1166 * @param plus_ammo 矢弾のダメージ修正
1167 * @param plus_bow 弓のダメージ修正
1168 * @param dam 基本ダメージ量
1171 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1175 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1180 crit = MIN(500, 900 / weight);
1181 num += dam * 3 / 2 * crit;
1184 crit = MIN(500, 1350 / weight);
1186 num += dam * 2 * crit;
1192 num += dam * 3 * crit;
1198 num += (10000 - i) * dam;
1205 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1206 * @param shooter_ptr プレーヤーへの参照ポインタ
1207 * @param weight 武器の重量
1208 * @param plus 武器のダメージ修正
1210 * @param meichuu 命中値
1211 * @param dokubari 毒針処理か否か
1214 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1217 if (dokubari) return dam;
1219 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1225 if (k < 400) num += (2 * dam + 5) * (400 - k);
1226 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1227 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1228 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1229 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1232 if (shooter_ptr->pclass == CLASS_NINJA)
1235 num += (4444 - i) * dam;
1241 num += (5000 - i) * dam;