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"
9 #include "inventory/inventory-object.h"
10 #include "io/targeting.h"
11 #include "main/sound-definitions-table.h"
12 #include "mind/snipe-types.h"
13 #include "monster-race/race-indice-types.h"
14 #include "monster/monster-status.h"
15 #include "monster/monster.h"
16 #include "mspell/monster-spell.h"
17 #include "object-enchant/artifact.h"
18 #include "object-enchant/tr-types.h"
19 #include "object/object-broken.h"
20 #include "object/object-flags.h"
21 #include "object/object-flavor.h"
22 #include "object/object-generator.h"
23 #include "object/object-hook.h"
24 #include "object/object-kind.h"
25 #include "object/object-mark-types.h"
26 #include "object/object-info.h"
27 #include "player/avatar.h"
28 #include "player/player-class.h"
29 #include "player/player-personalities-table.h"
30 #include "player/player-skill.h"
31 #include "player/player-status.h"
32 #include "spell/process-effect.h"
33 #include "spell/spells-type.h"
34 #include "sv-definition/sv-bow-types.h"
35 #include "util/util.h"
36 #include "view/display-main-window.h"
37 #include "world/world-object.h"
40 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
41 * Determines the odds of an object breaking when thrown at a monster
42 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
43 * @param tdam 計算途中のダメージ量
44 * @param m_ptr 目標モンスターの構造体参照ポインタ
45 * @return スレイ倍率をかけたダメージ量
47 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)
51 monster_race *r_ptr = &r_info[m_ptr->r_idx];
53 BIT_FLAGS flgs[TR_FLAG_SIZE];
54 object_flags(o_ptr, flgs);
56 /* Some "weapons" and "ammo" do extra damage */
63 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
65 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
67 r_ptr->r_flags3 |= RF3_ANIMAL;
69 if (mult < 17) mult = 17;
72 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
74 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
76 r_ptr->r_flags3 |= RF3_ANIMAL;
78 if (mult < 27) mult = 27;
81 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
83 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
85 r_ptr->r_flags3 |= RF3_EVIL;
87 if (mult < 15) mult = 15;
90 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
92 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
94 r_ptr->r_flags3 |= RF3_EVIL;
96 if (mult < 25) mult = 25;
99 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
101 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
103 r_ptr->r_flags2 |= RF2_HUMAN;
105 if (mult < 17) mult = 17;
108 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
110 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
112 r_ptr->r_flags2 |= RF2_HUMAN;
114 if (mult < 27) mult = 27;
117 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
119 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
121 r_ptr->r_flags3 |= RF3_UNDEAD;
123 if (mult < 20) mult = 20;
126 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
128 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
130 r_ptr->r_flags3 |= RF3_UNDEAD;
132 if (mult < 30) mult = 30;
135 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
137 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
139 r_ptr->r_flags3 |= RF3_DEMON;
141 if (mult < 20) mult = 20;
144 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
146 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
148 r_ptr->r_flags3 |= RF3_DEMON;
150 if (mult < 30) mult = 30;
153 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
155 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
157 r_ptr->r_flags3 |= RF3_ORC;
159 if (mult < 20) mult = 20;
162 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
164 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
166 r_ptr->r_flags3 |= RF3_ORC;
168 if (mult < 30) mult = 30;
171 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
173 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
175 r_ptr->r_flags3 |= RF3_TROLL;
178 if (mult < 20) mult = 20;
181 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
183 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
185 r_ptr->r_flags3 |= RF3_TROLL;
187 if (mult < 30) mult = 30;
190 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
192 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
194 r_ptr->r_flags3 |= RF3_GIANT;
196 if (mult < 20) mult = 20;
199 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
201 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
203 r_ptr->r_flags3 |= RF3_GIANT;
205 if (mult < 30) mult = 30;
208 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
210 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
212 r_ptr->r_flags3 |= RF3_DRAGON;
214 if (mult < 20) mult = 20;
217 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
219 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
221 r_ptr->r_flags3 |= RF3_DRAGON;
223 if (mult < 30) mult = 30;
224 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
225 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
229 if (have_flag(flgs, TR_BRAND_ACID))
231 /* Notice immunity */
232 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
234 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
236 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
241 if (mult < 17) mult = 17;
245 if (have_flag(flgs, TR_BRAND_ELEC))
247 /* Notice immunity */
248 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
250 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
252 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
257 if (mult < 17) mult = 17;
261 if (have_flag(flgs, TR_BRAND_FIRE))
263 /* Notice immunity */
264 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
266 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
268 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
271 /* Otherwise, take the damage */
274 if (r_ptr->flags3 & RF3_HURT_FIRE)
276 if (mult < 25) mult = 25;
277 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
279 r_ptr->r_flags3 |= RF3_HURT_FIRE;
282 else if (mult < 17) mult = 17;
286 if (have_flag(flgs, TR_BRAND_COLD))
288 /* Notice immunity */
289 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
291 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
293 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
296 /* Otherwise, take the damage */
299 if (r_ptr->flags3 & RF3_HURT_COLD)
301 if (mult < 25) mult = 25;
302 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
304 r_ptr->r_flags3 |= RF3_HURT_COLD;
307 else if (mult < 17) mult = 17;
311 if (have_flag(flgs, TR_BRAND_POIS))
313 /* Notice immunity */
314 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
316 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
318 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
321 /* Otherwise, take the damage */
324 if (mult < 17) mult = 17;
328 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
330 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
331 sniper_ptr->redraw |= (PR_MANA);
339 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
341 /* Return the total damage */
342 return (tdam * mult / 10);
348 * Fire an object from the pack or floor.
349 * @param item 射撃するオブジェクトの所持ID
350 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
354 * You may only fire items that "match" your missile launcher.
355 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
356 * See "calc_bonuses()" for more calculations and such.
357 * Note that "firing" a missile is MUCH better than "throwing" it.
358 * Note: "unseen" monsters are very hard to hit.
359 * Objects are more likely to break if they "attempt" to hit a monster.
360 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
361 * The "extra shot" code works by decreasing the amount of energy
362 * required to make each shot, spreading the shots out over time.
363 * Note that when firing missiles, the launcher multiplier is applied
364 * after all the bonuses are added in, making multipliers very useful.
365 * Note that Bows of "Extra Might" get extra range and an extra bonus
366 * for the damage multiplier.
367 * Note that Bows of "Extra Shots" give an extra shot.
370 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
374 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
375 int tdam_base, tdis, thits, tmul;
377 int cur_dis, visible;
385 bool hit_body = FALSE;
387 GAME_TEXT o_name[MAX_NLEN];
389 u16b path_g[512]; /* For calcuration of path length */
391 int msec = delay_factor * delay_factor * delay_factor;
394 bool stick_to = FALSE;
396 /* Access the item (if in the pack) */
399 o_ptr = &shooter_ptr->inventory_list[item];
403 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
406 /* Sniper - Cannot shot a single arrow twice */
407 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
409 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
411 /* Use the proper number of shots */
412 thits = shooter_ptr->num_fire;
414 /* Use a base distance */
417 /* Base damage from thrown object plus launcher bonus */
418 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
420 /* Actually "fire" the object */
421 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
422 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
423 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
425 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
427 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
428 tmul = bow_tmul(j_ptr->sval);
430 /* Get extra "power" from "extra might" */
431 if (shooter_ptr->xtra_might) tmul++;
433 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
435 /* Boost the damage */
440 tdis = 13 + tmul / 80;
441 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
443 if (shooter_ptr->concent)
444 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
449 project_length = tdis + 1;
451 /* Get a direction (or cancel) */
452 if (!get_aim_dir(shooter_ptr, &dir))
454 free_turn(shooter_ptr);
456 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
458 /* need not to reset project_length (already did)*/
463 /* Predict the "target" location */
464 tx = shooter_ptr->x + 99 * ddx[dir];
465 ty = shooter_ptr->y + 99 * ddy[dir];
467 /* Check for "target request" */
468 if ((dir == 5) && target_okay(shooter_ptr))
474 /* Get projection path length */
475 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
477 project_length = 0; /* reset to default */
479 /* Don't shoot at my feet */
480 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
482 free_turn(shooter_ptr);
484 /* project_length is already reset to 0 */
490 /* Take a (partial) turn */
491 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
492 shooter_ptr->is_fired = TRUE;
494 /* Sniper - Difficult to shot twice at 1 turn */
495 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
497 /* Sniper - Repeat shooting when double shots */
498 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
501 /* Start at the player */
505 object_copy(q_ptr, o_ptr);
510 vary_item(shooter_ptr, item, -1);
513 handle_stuff(shooter_ptr);
518 /* The shot does not hit yet */
521 /* Travel until stopped */
522 for (cur_dis = 0; cur_dis <= tdis; )
526 /* Hack -- Stop at the target */
527 if ((y == ty) && (x == tx)) break;
529 /* Calculate the new location (see "project()") */
532 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
535 if (snipe_type == SP_KILL_WALL)
537 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
539 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
541 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
542 /* Forget the wall */
543 g_ptr->info &= ~(CAVE_MARK);
544 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
546 /* Destroy the wall */
547 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
554 /* Stopped by walls/doors */
555 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;
557 /* Advance the distance */
561 if (snipe_type == SP_LITE)
563 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
564 note_spot(shooter_ptr, ny, nx);
565 lite_spot(shooter_ptr, ny, nx);
568 /* The player can see the (on screen) missile */
569 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
571 char c = object_char(q_ptr);
572 byte a = object_attr(q_ptr);
574 /* Draw, Hilite, Fresh, Pause, Erase */
575 print_rel(shooter_ptr, c, a, ny, nx);
576 move_cursor_relative(ny, nx);
578 Term_xtra(TERM_XTRA_DELAY, msec);
579 lite_spot(shooter_ptr, ny, nx);
583 /* The player cannot see the missile */
586 /* Pause anyway, for consistancy */
587 Term_xtra(TERM_XTRA_DELAY, msec);
591 if (snipe_type == SP_KILL_TRAP)
593 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
594 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
598 if (snipe_type == SP_EVILNESS)
600 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
601 note_spot(shooter_ptr, ny, nx);
602 lite_spot(shooter_ptr, ny, nx);
608 /* Save the new location */
612 /* Monster here, Try to hit it */
613 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
615 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
617 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
618 monster_race *r_ptr = &r_info[m_ptr->r_idx];
620 /* Check the visibility */
623 /* Note the collision */
626 if (MON_CSLEEP(m_ptr))
628 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
629 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
632 if ((r_ptr->level + 10) > shooter_ptr->lev)
634 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
635 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
638 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
639 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
640 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
641 else if (shooter_ptr->lev > 34) amount = 2;
642 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
643 shooter_ptr->update |= (PU_BONUS);
647 if (shooter_ptr->riding)
649 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
650 && ((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)
653 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
654 shooter_ptr->update |= (PU_BONUS);
658 /* Did we hit it (penalize range) */
659 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
662 int tdam = tdam_base;
664 /* Get extra damage from concentration */
665 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
667 /* Handle unseen monster */
670 /* Invisible monster */
671 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
674 /* Handle visible monster */
677 GAME_TEXT m_name[MAX_NLEN];
679 /* Get "the monster" or "it" */
680 monster_desc(shooter_ptr, m_name, m_ptr, 0);
682 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
686 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
687 health_track(shooter_ptr, c_mon_ptr->m_idx);
691 if (snipe_type == SP_NEEDLE)
693 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
694 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
696 GAME_TEXT m_name[MAX_NLEN];
698 /* Get "the monster" or "it" */
699 monster_desc(shooter_ptr, m_name, m_ptr, 0);
701 tdam = m_ptr->hp + 1;
702 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
708 /* Apply special damage */
709 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
710 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
712 /* No negative damage */
713 if (tdam < 0) tdam = 0;
715 /* Modify the damage */
716 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
719 msg_format_wizard(CHEAT_MONSTER,
720 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
721 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
724 if (snipe_type == SP_EXPLODE)
726 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
728 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
729 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
734 if (snipe_type == SP_HOLYNESS)
736 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
737 note_spot(shooter_ptr, ny, nx);
738 lite_spot(shooter_ptr, ny, nx);
741 /* Hit the monster, check for death */
742 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
751 if (object_is_fixed_artifact(q_ptr) &&
752 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
754 GAME_TEXT m_name[MAX_NLEN];
756 monster_desc(shooter_ptr, m_name, m_ptr, 0);
759 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
762 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
764 /* Anger the monster */
765 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
767 if (fear && m_ptr->ml)
769 GAME_TEXT m_name[MAX_NLEN];
771 monster_desc(shooter_ptr, m_name, m_ptr, 0);
772 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
775 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
778 if (snipe_type == SP_RUSH)
780 int n = randint1(5) + 3;
781 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
783 for (; cur_dis <= tdis; )
790 /* Calculate the new location (see "project()") */
791 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
793 /* Stopped by wilderness boundary */
794 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
796 /* Stopped by walls/doors */
797 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
799 /* Stopped by monsters */
800 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
802 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
803 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
808 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
810 lite_spot(shooter_ptr, ny, nx);
811 lite_spot(shooter_ptr, oy, ox);
814 Term_xtra(TERM_XTRA_DELAY, msec);
826 if (snipe_type == SP_PIERCE)
828 if (shooter_ptr->concent < 1) break;
829 shooter_ptr->concent--;
838 /* Chance of breakage (during attacks) */
839 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
843 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
844 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
845 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
849 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
850 if (object_is_fixed_artifact(q_ptr))
852 a_info[j_ptr->name1].cur_num = 0;
857 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
858 object_copy(o_ptr, q_ptr);
861 o_ptr->marked &= OM_TOUCHED;
863 /* Forget location */
864 o_ptr->iy = o_ptr->ix = 0;
866 /* Memorize monster */
867 o_ptr->held_m_idx = m_idx;
870 o_ptr->next_o_idx = m_ptr->hold_o_idx;
873 m_ptr->hold_o_idx = o_idx;
875 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
877 /* Drop (or break) near that location */
878 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
882 /* Drop (or break) near that location */
883 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
886 /* Sniper - Repeat shooting when double shots */
889 /* Sniper - Loose his/her concentration after any shot */
890 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
895 * @brief プレイヤーからモンスターへの射撃命中判定 /
896 * Determine if the player "hits" a monster (normal combat).
897 * @param chance 基本命中値
898 * @param m_ptr モンスターの構造体参照ポインタ
899 * @param vis 目標を視界に捕らえているならばTRUEを指定
900 * @param o_name メッセージ表示時のモンスター名
901 * @return 命中と判定された場合TRUEを返す
902 * @note Always miss 5%, always hit 5%, otherwise random.
904 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
908 monster_race *r_ptr = &r_info[m_ptr->r_idx];
910 /* Percentile dice */
913 /* Snipers with high-concentration reduce instant miss percentage.*/
914 k += shooter_ptr->concent;
916 /* Hack -- Instant miss or hit */
917 if (k <= 5) return FALSE;
918 if (k > 95) return TRUE;
920 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
921 if (one_in_(20)) return FALSE;
924 if (chance <= 0) return FALSE;
927 if (shooter_ptr->concent)
929 ac *= (8 - shooter_ptr->concent);
933 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
935 /* Invisible monsters are harder to hit */
936 if (!vis) chance = (chance + 1) / 2;
938 /* Power competes against armor */
939 if (randint0(chance) < (ac * 3 / 4))
941 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
943 GAME_TEXT m_name[MAX_NLEN];
944 monster_desc(shooter_ptr, m_name, m_ptr, 0);
945 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
958 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
959 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
960 * @param weight 矢弾の重量
961 * @param plus_ammo 矢弾の命中修正
962 * @param plus_bow 弓の命中修正
963 * @param dam 現在算出中のダメージ値
964 * @return クリティカル修正が入ったダメージ値
966 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
969 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
971 /* Extract "shot" power */
972 i = shooter_ptr->to_h_b + plus_ammo;
974 if (shooter_ptr->tval_ammo == TV_BOLT)
975 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
977 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
980 /* Snipers can shot more critically with crossbows */
981 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
982 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
984 /* Good bow makes more critical */
985 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
988 if (randint1(10000) <= i)
990 k = weight * randint1(500);
994 msg_print(_("手ごたえがあった!", "It was a good hit!"));
999 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1004 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1016 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1017 * @param sval 射撃武器のアイテム副分類ID
1018 * @return 消費する基本エネルギー
1020 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1022 ENERGY energy = 10000;
1024 /* Analyze the launcher */
1027 /* Sling and ammo */
1034 /* Short Bow and Arrow */
1041 /* Long Bow and Arrow */
1048 /* Bow of irresponsiblity and Arrow */
1055 /* Light Crossbow and Bolt */
1062 /* Heavy Crossbow and Bolt */
1077 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1081 /* Analyze the launcher */
1084 /* Sling and ammo */
1091 /* Short Bow and Arrow */
1098 /* Long Bow and Arrow */
1105 /* Bow of irresponsiblity and Arrow */
1112 /* Light Crossbow and Bolt */
1119 /* Heavy Crossbow and Bolt */
1132 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1133 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1134 * @param plus_ammo 矢弾のダメージ修正
1135 * @param plus_bow 弓のダメージ修正
1137 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1139 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1142 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1144 /* Extract "shot" power */
1145 i = shooter_ptr->to_h_b + plus_ammo;
1147 if (shooter_ptr->tval_ammo == TV_BOLT)
1148 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1150 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1152 /* Snipers can shot more critically with crossbows */
1153 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1154 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1156 /* Good bow makes more critical */
1157 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1165 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1166 * @param weight 武器の重量
1167 * @param plus_ammo 矢弾のダメージ修正
1168 * @param plus_bow 弓のダメージ修正
1169 * @param dam 基本ダメージ量
1172 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1176 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1181 crit = MIN(500, 900 / weight);
1182 num += dam * 3 / 2 * crit;
1185 crit = MIN(500, 1350 / weight);
1187 num += dam * 2 * crit;
1193 num += dam * 3 * crit;
1199 num += (10000 - i) * dam;
1206 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1207 * @param shooter_ptr プレーヤーへの参照ポインタ
1208 * @param weight 武器の重量
1209 * @param plus 武器のダメージ修正
1211 * @param meichuu 命中値
1212 * @param dokubari 毒針処理か否か
1215 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1218 if (dokubari) return dam;
1220 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1226 if (k < 400) num += (2 * dam + 5) * (400 - k);
1227 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1228 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1229 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1230 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1233 if (shooter_ptr->pclass == CLASS_NINJA)
1236 num += (4444 - i) * dam;
1242 num += (5000 - i) * dam;