1 #include "combat/shoot.h"
2 #include "art-definition/art-bow-types.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/stuff-handler.h"
6 #include "effect/effect-characteristics.h"
7 #include "effect/spells-effect-util.h"
8 #include "flavor/flavor-describer.h"
9 #include "flavor/object-flavor-types.h"
10 #include "floor/floor-object.h"
11 #include "game-option/cheat-types.h"
12 #include "game-option/special-options.h"
13 #include "grid/feature.h"
14 #include "grid/feature-flag-types.h"
15 #include "grid/grid.h"
16 #include "inventory/inventory-object.h"
17 #include "inventory/inventory-slot-types.h"
18 #include "io/cursor.h"
19 #include "io/screen-util.h"
20 #include "io/targeting.h"
21 #include "main/sound-definitions-table.h"
22 #include "main/sound-of-music.h"
23 #include "mind/mind-sniper.h"
24 #include "mind/snipe-types.h"
25 #include "monster-floor/monster-death.h"
26 #include "monster-floor/monster-move.h"
27 #include "monster-race/monster-race.h"
28 #include "monster-race/race-flags-resistance.h"
29 #include "monster-race/race-flags1.h"
30 #include "monster-race/race-flags2.h"
31 #include "monster-race/race-flags3.h"
32 #include "monster-race/race-flags7.h"
33 #include "monster-race/race-indice-types.h"
34 #include "monster/monster-describer.h"
35 #include "monster/monster-info.h"
36 #include "monster/monster-status.h"
37 #include "monster/monster-update.h"
38 #include "object-enchant/artifact.h"
39 #include "object-enchant/tr-types.h"
40 #include "object-hook/hook-enchant.h"
41 #include "object/object-broken.h"
42 #include "object/object-flags.h"
43 #include "object/object-generator.h"
44 #include "object/object-info.h"
45 #include "object/object-kind.h"
46 #include "object/object-mark-types.h"
47 #include "player/avatar.h"
48 #include "player/player-class.h"
49 #include "player/player-personalities-types.h"
50 #include "player/player-skill.h"
51 #include "player/player-status.h"
52 #include "spell/process-effect.h"
53 #include "spell/spell-types.h"
54 #include "sv-definition/sv-bow-types.h"
55 #include "util/bit-flags-calculator.h"
56 #include "view/display-messages.h"
57 #include "wizard/wizard-messages.h"
58 #include "world/world-object.h"
61 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
62 * Determines the odds of an object breaking when thrown at a monster
63 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
64 * @param tdam 計算途中のダメージ量
65 * @param m_ptr 目標モンスターの構造体参照ポインタ
66 * @return スレイ倍率をかけたダメージ量
68 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)
72 monster_race *r_ptr = &r_info[m_ptr->r_idx];
74 BIT_FLAGS flgs[TR_FLAG_SIZE];
75 object_flags(sniper_ptr, o_ptr, flgs);
77 /* Some "weapons" and "ammo" do extra damage */
78 switch (o_ptr->tval) {
82 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL)) {
83 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
84 r_ptr->r_flags3 |= RF3_ANIMAL;
90 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL)) {
91 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
92 r_ptr->r_flags3 |= RF3_ANIMAL;
98 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL)) {
99 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
100 r_ptr->r_flags3 |= RF3_EVIL;
106 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL)) {
107 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
108 r_ptr->r_flags3 |= RF3_EVIL;
114 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN)) {
115 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
116 r_ptr->r_flags2 |= RF2_HUMAN;
122 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN)) {
123 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
124 r_ptr->r_flags2 |= RF2_HUMAN;
130 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD)) {
131 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
132 r_ptr->r_flags3 |= RF3_UNDEAD;
138 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD)) {
139 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
140 r_ptr->r_flags3 |= RF3_UNDEAD;
146 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON)) {
147 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
148 r_ptr->r_flags3 |= RF3_DEMON;
154 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON)) {
155 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
156 r_ptr->r_flags3 |= RF3_DEMON;
162 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC)) {
163 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
164 r_ptr->r_flags3 |= RF3_ORC;
170 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC)) {
171 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
172 r_ptr->r_flags3 |= RF3_ORC;
178 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL)) {
179 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
180 r_ptr->r_flags3 |= RF3_TROLL;
187 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL)) {
188 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
189 r_ptr->r_flags3 |= RF3_TROLL;
195 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT)) {
196 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
197 r_ptr->r_flags3 |= RF3_GIANT;
203 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT)) {
204 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
205 r_ptr->r_flags3 |= RF3_GIANT;
211 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON)) {
212 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
213 r_ptr->r_flags3 |= RF3_DRAGON;
219 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON)) {
220 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
221 r_ptr->r_flags3 |= RF3_DRAGON;
225 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) && (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
229 if (have_flag(flgs, TR_BRAND_ACID)) {
230 /* Notice immunity */
231 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK) {
232 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
233 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
241 if (have_flag(flgs, TR_BRAND_ELEC)) {
242 /* Notice immunity */
243 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK) {
244 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
245 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
253 if (have_flag(flgs, TR_BRAND_FIRE)) {
254 /* Notice immunity */
255 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK) {
256 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
257 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
260 /* Otherwise, take the damage */
262 if (r_ptr->flags3 & RF3_HURT_FIRE) {
265 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
266 r_ptr->r_flags3 |= RF3_HURT_FIRE;
268 } else if (mult < 17)
273 if (have_flag(flgs, TR_BRAND_COLD)) {
274 /* Notice immunity */
275 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK) {
276 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
277 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
280 /* Otherwise, take the damage */
282 if (r_ptr->flags3 & RF3_HURT_COLD) {
285 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
286 r_ptr->r_flags3 |= RF3_HURT_COLD;
288 } else if (mult < 17)
293 if (have_flag(flgs, TR_BRAND_POIS)) {
294 /* Notice immunity */
295 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK) {
296 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
297 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
300 /* Otherwise, take the damage */
307 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30))) {
308 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
309 sniper_ptr->redraw |= (PR_MANA);
318 mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
320 /* Return the total damage */
321 return (tdam * mult / 10);
326 * Fire an object from the pack or floor.
327 * @param item 射撃するオブジェクトの所持ID
328 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
332 * You may only fire items that "match" your missile launcher.
333 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
334 * See "calc_bonuses()" for more calculations and such.
335 * Note that "firing" a missile is MUCH better than "throwing" it.
336 * Note: "unseen" monsters are very hard to hit.
337 * Objects are more likely to break if they "attempt" to hit a monster.
338 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
339 * The "extra shot" code works by decreasing the amount of energy
340 * required to make each shot, spreading the shots out over time.
341 * Note that when firing missiles, the launcher multiplier is applied
342 * after all the bonuses are added in, making multipliers very useful.
343 * Note that Bows of "Extra Might" get extra range and an extra bonus
344 * for the damage multiplier.
345 * Note that Bows of "Extra Shots" give an extra shot.
348 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
352 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
353 int tdam_base, tdis, thits, tmul;
355 int cur_dis, visible;
363 bool hit_body = FALSE;
365 GAME_TEXT o_name[MAX_NLEN];
367 u16b path_g[512]; /* For calcuration of path length */
369 int msec = delay_factor * delay_factor * delay_factor;
372 bool stick_to = FALSE;
374 /* Access the item (if in the pack) */
376 o_ptr = &shooter_ptr->inventory_list[item];
378 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
381 /* Sniper - Cannot shot a single arrow twice */
382 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2))
383 snipe_type = SP_NONE;
385 describe_flavor(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
387 /* Use the proper number of shots */
388 thits = shooter_ptr->num_fire;
390 /* Use a base distance */
393 /* Base damage from thrown object plus launcher bonus */
394 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
396 /* Actually "fire" the object */
397 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
398 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
399 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
401 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
403 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
404 tmul = bow_tmul(j_ptr->sval);
406 /* Get extra "power" from "extra might" */
407 if (shooter_ptr->xtra_might)
410 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
412 /* Boost the damage */
417 tdis = 13 + tmul / 80;
418 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW)) {
419 if (shooter_ptr->concent)
420 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
425 project_length = tdis + 1;
427 /* Get a direction (or cancel) */
428 if (!get_aim_dir(shooter_ptr, &dir)) {
429 free_turn(shooter_ptr);
431 if (snipe_type == SP_AWAY)
432 snipe_type = SP_NONE;
434 /* need not to reset project_length (already did)*/
439 /* Predict the "target" location */
440 tx = shooter_ptr->x + 99 * ddx[dir];
441 ty = shooter_ptr->y + 99 * ddy[dir];
443 /* Check for "target request" */
444 if ((dir == 5) && target_okay(shooter_ptr)) {
449 /* Get projection path length */
450 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
452 project_length = 0; /* reset to default */
454 /* Don't shoot at my feet */
455 if (tx == shooter_ptr->x && ty == shooter_ptr->y) {
456 free_turn(shooter_ptr);
458 /* project_length is already reset to 0 */
463 /* Take a (partial) turn */
464 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
465 shooter_ptr->is_fired = TRUE;
467 /* Sniper - Difficult to shot twice at 1 turn */
468 if (snipe_type == SP_DOUBLE)
469 shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
471 /* Sniper - Repeat shooting when double shots */
472 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++) {
474 /* Start at the player */
478 object_copy(q_ptr, o_ptr);
483 vary_item(shooter_ptr, item, -1);
486 handle_stuff(shooter_ptr);
491 /* The shot does not hit yet */
494 /* Travel until stopped */
495 for (cur_dis = 0; cur_dis <= tdis;) {
498 /* Hack -- Stop at the target */
499 if ((y == ty) && (x == tx))
502 /* Calculate the new location (see "project()") */
505 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
508 if (snipe_type == SP_KILL_WALL) {
509 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
511 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx) {
512 if (g_ptr->info & (CAVE_MARK))
513 msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
514 /* Forget the wall */
515 g_ptr->info &= ~(CAVE_MARK);
516 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
518 /* Destroy the wall */
519 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
526 /* Stopped by walls/doors */
527 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)
530 /* Advance the distance */
534 if (snipe_type == SP_LITE) {
535 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
536 note_spot(shooter_ptr, ny, nx);
537 lite_spot(shooter_ptr, ny, nx);
540 /* The player can see the (on screen) missile */
541 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx)) {
542 SYMBOL_CODE c = object_char(q_ptr);
543 byte a = object_attr(q_ptr);
545 /* Draw, Hilite, Fresh, Pause, Erase */
546 print_rel(shooter_ptr, c, a, ny, nx);
547 move_cursor_relative(ny, nx);
549 Term_xtra(TERM_XTRA_DELAY, msec);
550 lite_spot(shooter_ptr, ny, nx);
554 /* The player cannot see the missile */
556 /* Pause anyway, for consistancy */
557 Term_xtra(TERM_XTRA_DELAY, msec);
561 if (snipe_type == SP_KILL_TRAP) {
562 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP, (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
566 if (snipe_type == SP_EVILNESS) {
567 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
568 note_spot(shooter_ptr, ny, nx);
569 lite_spot(shooter_ptr, ny, nx);
575 /* Save the new location */
579 /* Monster here, Try to hit it */
580 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
581 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
583 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
584 monster_race *r_ptr = &r_info[m_ptr->r_idx];
586 /* Check the visibility */
589 /* Note the collision */
592 if (monster_csleep_remaining(m_ptr)) {
593 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5))
594 chg_virtue(shooter_ptr, V_COMPASSION, -1);
595 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5))
596 chg_virtue(shooter_ptr, V_HONOUR, -1);
599 if ((r_ptr->level + 10) > shooter_ptr->lev) {
600 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
601 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval]) {
603 if (now_exp < WEAPON_EXP_BEGINNER)
605 else if (now_exp < WEAPON_EXP_SKILLED)
607 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19))
609 else if (shooter_ptr->lev > 34)
611 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
612 shooter_ptr->update |= (PU_BONUS);
616 if (shooter_ptr->riding) {
617 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
618 && ((shooter_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200
619 < r_info[shooter_ptr->current_floor_ptr->m_list[shooter_ptr->riding].r_idx].level)
621 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
622 shooter_ptr->update |= (PU_BONUS);
626 /* Did we hit it (penalize range) */
627 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name)) {
629 int tdam = tdam_base;
631 /* Get extra damage from concentration */
632 if (shooter_ptr->concent)
633 tdam = boost_concentration_damage(shooter_ptr, tdam);
635 /* Handle unseen monster */
637 /* Invisible monster */
638 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
641 /* Handle visible monster */
643 GAME_TEXT m_name[MAX_NLEN];
645 /* Get "the monster" or "it" */
646 monster_desc(shooter_ptr, m_name, m_ptr, 0);
648 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
651 if (!shooter_ptr->image)
652 monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
653 health_track(shooter_ptr, c_mon_ptr->m_idx);
657 if (snipe_type == SP_NEEDLE) {
658 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1) && !(r_ptr->flags1 & RF1_UNIQUE)
659 && !(r_ptr->flags7 & RF7_UNIQUE2)) {
660 GAME_TEXT m_name[MAX_NLEN];
662 /* Get "the monster" or "it" */
663 monster_desc(shooter_ptr, m_name, m_ptr, 0);
665 tdam = m_ptr->hp + 1;
666 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
670 /* Apply special damage */
671 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
672 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
674 /* No negative damage */
678 /* Modify the damage */
679 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
682 msg_format_wizard(shooter_ptr, CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"), tdam,
683 m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
686 if (snipe_type == SP_EXPLODE) {
687 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
689 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
690 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
695 if (snipe_type == SP_HOLYNESS) {
696 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
697 note_spot(shooter_ptr, ny, nx);
698 lite_spot(shooter_ptr, ny, nx);
701 /* Hit the monster, check for death */
702 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr)))) {
709 if (object_is_fixed_artifact(q_ptr) && (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0)) {
710 GAME_TEXT m_name[MAX_NLEN];
712 monster_desc(shooter_ptr, m_name, m_ptr, 0);
715 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
718 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
720 /* Anger the monster */
722 anger_monster(shooter_ptr, m_ptr);
724 if (fear && m_ptr->ml) {
725 GAME_TEXT m_name[MAX_NLEN];
727 monster_desc(shooter_ptr, m_name, m_ptr, 0);
728 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
731 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
734 if (snipe_type == SP_RUSH) {
735 int n = randint1(5) + 3;
736 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
738 for (; cur_dis <= tdis;) {
745 /* Calculate the new location (see "project()") */
746 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
748 /* Stopped by wilderness boundary */
749 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx))
752 /* Stopped by walls/doors */
753 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0))
756 /* Stopped by monsters */
757 if (!is_cave_empty_bold(shooter_ptr, ny, nx))
760 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
761 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
766 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
768 lite_spot(shooter_ptr, ny, nx);
769 lite_spot(shooter_ptr, oy, ox);
772 Term_xtra(TERM_XTRA_DELAY, msec);
784 if (snipe_type == SP_PIERCE) {
785 if (shooter_ptr->concent < 1)
787 shooter_ptr->concent--;
796 /* Chance of breakage (during attacks) */
797 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
800 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
801 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
802 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
805 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
806 if (object_is_fixed_artifact(q_ptr)) {
807 a_info[j_ptr->name1].cur_num = 0;
812 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
813 object_copy(o_ptr, q_ptr);
816 o_ptr->marked &= OM_TOUCHED;
818 /* Forget location */
819 o_ptr->iy = o_ptr->ix = 0;
821 /* Memorize monster */
822 o_ptr->held_m_idx = m_idx;
825 o_ptr->next_o_idx = m_ptr->hold_o_idx;
828 m_ptr->hold_o_idx = o_idx;
829 } else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT)) {
830 /* Drop (or break) near that location */
831 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
833 /* Drop (or break) near that location */
834 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
837 /* Sniper - Repeat shooting when double shots */
840 /* Sniper - Loose his/her concentration after any shot */
841 if (shooter_ptr->concent)
842 reset_concentration(shooter_ptr, FALSE);
846 * @brief プレイヤーからモンスターへの射撃命中判定 /
847 * Determine if the player "hits" a monster (normal combat).
848 * @param chance 基本命中値
849 * @param m_ptr モンスターの構造体参照ポインタ
850 * @param vis 目標を視界に捕らえているならばTRUEを指定
851 * @param o_name メッセージ表示時のモンスター名
852 * @return 命中と判定された場合TRUEを返す
853 * @note Always miss 5%, always hit 5%, otherwise random.
855 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char *o_name)
859 monster_race *r_ptr = &r_info[m_ptr->r_idx];
861 /* Percentile dice */
864 /* Snipers with high-concentration reduce instant miss percentage.*/
865 k += shooter_ptr->concent;
867 /* Hack -- Instant miss or hit */
873 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
882 if (shooter_ptr->concent) {
883 ac *= (8 - shooter_ptr->concent);
887 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
890 /* Invisible monsters are harder to hit */
892 chance = (chance + 1) / 2;
894 /* Power competes against armor */
895 if (randint0(chance) < (ac * 3 / 4)) {
896 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) {
897 GAME_TEXT m_name[MAX_NLEN];
898 monster_desc(shooter_ptr, m_name, m_ptr, 0);
899 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
909 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
910 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
911 * @param weight 矢弾の重量
912 * @param plus_ammo 矢弾の命中修正
913 * @param plus_bow 弓の命中修正
914 * @param dam 現在算出中のダメージ値
915 * @return クリティカル修正が入ったダメージ値
917 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
920 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
922 /* Extract "shot" power */
923 i = shooter_ptr->to_h_b + plus_ammo;
925 if (shooter_ptr->tval_ammo == TV_BOLT)
926 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
928 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
930 /* Snipers can shot more critically with crossbows */
931 if (shooter_ptr->concent)
932 i += ((i * shooter_ptr->concent) / 5);
933 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT))
936 /* Good bow makes more critical */
937 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
940 if (randint1(10000) <= i) {
941 k = weight * randint1(500);
944 msg_print(_("手ごたえがあった!", "It was a good hit!"));
946 } else if (k < 1350) {
947 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
950 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
959 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
960 * @param sval 射撃武器のアイテム副分類ID
961 * @return 消費する基本エネルギー
963 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
965 ENERGY energy = 10000;
967 /* Analyze the launcher */
975 /* Short Bow and Arrow */
981 /* Long Bow and Arrow */
987 /* Bow of irresponsiblity and Arrow */
988 case SV_NAMAKE_BOW: {
993 /* Light Crossbow and Bolt */
994 case SV_LIGHT_XBOW: {
999 /* Heavy Crossbow and Bolt */
1000 case SV_HEAVY_XBOW: {
1012 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1016 /* Analyze the launcher */
1018 /* Sling and ammo */
1024 /* Short Bow and Arrow */
1025 case SV_SHORT_BOW: {
1030 /* Long Bow and Arrow */
1036 /* Bow of irresponsiblity and Arrow */
1037 case SV_NAMAKE_BOW: {
1042 /* Light Crossbow and Bolt */
1043 case SV_LIGHT_XBOW: {
1048 /* Heavy Crossbow and Bolt */
1049 case SV_HEAVY_XBOW: {
1059 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1060 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1061 * @param plus_ammo 矢弾のダメージ修正
1062 * @param plus_bow 弓のダメージ修正
1064 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1066 HIT_POINT calc_crit_ratio_shot(player_type *shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1069 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1071 /* Extract "shot" power */
1072 i = shooter_ptr->to_h_b + plus_ammo;
1074 if (shooter_ptr->tval_ammo == TV_BOLT)
1075 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1077 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1079 /* Snipers can shot more critically with crossbows */
1080 if (shooter_ptr->concent)
1081 i += ((i * shooter_ptr->concent) / 5);
1082 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT))
1085 /* Good bow makes more critical */
1086 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1095 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1096 * @param weight 武器の重量
1097 * @param plus_ammo 矢弾のダメージ修正
1098 * @param plus_bow 弓のダメージ修正
1099 * @param dam 基本ダメージ量
1102 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1106 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1111 crit = MIN(500, 900 / weight);
1112 num += dam * 3 / 2 * crit;
1115 crit = MIN(500, 1350 / weight);
1117 num += dam * 2 * crit;
1122 num += dam * 3 * crit;
1128 num += (10000 - i) * dam;
1135 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1136 * @param shooter_ptr プレーヤーへの参照ポインタ
1137 * @param weight 武器の重量
1138 * @param plus 武器のダメージ修正
1140 * @param meichuu 命中値
1141 * @param dokubari 毒針処理か否か
1144 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1150 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1158 num += (2 * dam + 5) * (400 - k);
1160 num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1161 if (k > (700 - 650) && k < 900)
1162 num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1163 if (k > (900 - 650) && k < 1300)
1164 num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1165 if (k > (1300 - 650))
1166 num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1169 if (shooter_ptr->pclass == CLASS_NINJA) {
1171 num += (4444 - i) * dam;
1175 num += (5000 - i) * dam;