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 "mind/snipe-types.h"
14 #include "monster-race/race-flags-resistance.h"
15 #include "monster-race/race-flags1.h"
16 #include "monster-race/race-flags2.h"
17 #include "monster-race/race-flags3.h"
18 #include "monster-race/race-flags7.h"
19 #include "monster-race/race-indice-types.h"
20 #include "monster/monster-describer.h"
21 #include "monster-floor/monster-death.h"
22 #include "monster/monster-status.h"
23 #include "monster/monster-info.h"
24 #include "monster-floor/monster-move.h"
25 #include "monster/monster-update.h"
26 #include "mspell/monster-spell.h"
27 #include "object-enchant/artifact.h"
28 #include "object-enchant/tr-types.h"
29 #include "object/object-broken.h"
30 #include "object/object-flags.h"
31 #include "object/object-flavor.h"
32 #include "object/object-generator.h"
33 #include "object/object-hook.h"
34 #include "object/object-kind.h"
35 #include "object/object-mark-types.h"
36 #include "object/object-info.h"
37 #include "player/avatar.h"
38 #include "player/player-class.h"
39 #include "player/player-personalities-table.h"
40 #include "player/player-skill.h"
41 #include "player/player-status.h"
42 #include "spell/process-effect.h"
43 #include "spell/spells-type.h"
44 #include "sv-definition/sv-bow-types.h"
45 #include "util/util.h"
46 #include "view/display-main-window.h"
47 #include "world/world-object.h"
50 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
51 * Determines the odds of an object breaking when thrown at a monster
52 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
53 * @param tdam 計算途中のダメージ量
54 * @param m_ptr 目標モンスターの構造体参照ポインタ
55 * @return スレイ倍率をかけたダメージ量
57 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)
61 monster_race *r_ptr = &r_info[m_ptr->r_idx];
63 BIT_FLAGS flgs[TR_FLAG_SIZE];
64 object_flags(o_ptr, flgs);
66 /* Some "weapons" and "ammo" do extra damage */
73 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
75 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
77 r_ptr->r_flags3 |= RF3_ANIMAL;
79 if (mult < 17) mult = 17;
82 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
84 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
86 r_ptr->r_flags3 |= RF3_ANIMAL;
88 if (mult < 27) mult = 27;
91 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
93 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
95 r_ptr->r_flags3 |= RF3_EVIL;
97 if (mult < 15) mult = 15;
100 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
102 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
104 r_ptr->r_flags3 |= RF3_EVIL;
106 if (mult < 25) mult = 25;
109 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
111 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
113 r_ptr->r_flags2 |= RF2_HUMAN;
115 if (mult < 17) mult = 17;
118 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
120 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
122 r_ptr->r_flags2 |= RF2_HUMAN;
124 if (mult < 27) mult = 27;
127 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
129 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
131 r_ptr->r_flags3 |= RF3_UNDEAD;
133 if (mult < 20) mult = 20;
136 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
138 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
140 r_ptr->r_flags3 |= RF3_UNDEAD;
142 if (mult < 30) mult = 30;
145 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
147 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
149 r_ptr->r_flags3 |= RF3_DEMON;
151 if (mult < 20) mult = 20;
154 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
156 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
158 r_ptr->r_flags3 |= RF3_DEMON;
160 if (mult < 30) mult = 30;
163 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
165 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
167 r_ptr->r_flags3 |= RF3_ORC;
169 if (mult < 20) mult = 20;
172 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
174 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
176 r_ptr->r_flags3 |= RF3_ORC;
178 if (mult < 30) mult = 30;
181 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
183 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
185 r_ptr->r_flags3 |= RF3_TROLL;
188 if (mult < 20) mult = 20;
191 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
193 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
195 r_ptr->r_flags3 |= RF3_TROLL;
197 if (mult < 30) mult = 30;
200 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
202 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
204 r_ptr->r_flags3 |= RF3_GIANT;
206 if (mult < 20) mult = 20;
209 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
211 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
213 r_ptr->r_flags3 |= RF3_GIANT;
215 if (mult < 30) mult = 30;
218 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
220 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
222 r_ptr->r_flags3 |= RF3_DRAGON;
224 if (mult < 20) mult = 20;
227 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
229 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
231 r_ptr->r_flags3 |= RF3_DRAGON;
233 if (mult < 30) mult = 30;
234 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
235 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
239 if (have_flag(flgs, TR_BRAND_ACID))
241 /* Notice immunity */
242 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
244 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
246 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
251 if (mult < 17) mult = 17;
255 if (have_flag(flgs, TR_BRAND_ELEC))
257 /* Notice immunity */
258 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
260 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
262 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
267 if (mult < 17) mult = 17;
271 if (have_flag(flgs, TR_BRAND_FIRE))
273 /* Notice immunity */
274 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
276 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
278 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
281 /* Otherwise, take the damage */
284 if (r_ptr->flags3 & RF3_HURT_FIRE)
286 if (mult < 25) mult = 25;
287 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
289 r_ptr->r_flags3 |= RF3_HURT_FIRE;
292 else if (mult < 17) mult = 17;
296 if (have_flag(flgs, TR_BRAND_COLD))
298 /* Notice immunity */
299 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
301 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
303 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
306 /* Otherwise, take the damage */
309 if (r_ptr->flags3 & RF3_HURT_COLD)
311 if (mult < 25) mult = 25;
312 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
314 r_ptr->r_flags3 |= RF3_HURT_COLD;
317 else if (mult < 17) mult = 17;
321 if (have_flag(flgs, TR_BRAND_POIS))
323 /* Notice immunity */
324 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
326 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
328 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
331 /* Otherwise, take the damage */
334 if (mult < 17) mult = 17;
338 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
340 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
341 sniper_ptr->redraw |= (PR_MANA);
349 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
351 /* Return the total damage */
352 return (tdam * mult / 10);
358 * Fire an object from the pack or floor.
359 * @param item 射撃するオブジェクトの所持ID
360 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
364 * You may only fire items that "match" your missile launcher.
365 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
366 * See "calc_bonuses()" for more calculations and such.
367 * Note that "firing" a missile is MUCH better than "throwing" it.
368 * Note: "unseen" monsters are very hard to hit.
369 * Objects are more likely to break if they "attempt" to hit a monster.
370 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
371 * The "extra shot" code works by decreasing the amount of energy
372 * required to make each shot, spreading the shots out over time.
373 * Note that when firing missiles, the launcher multiplier is applied
374 * after all the bonuses are added in, making multipliers very useful.
375 * Note that Bows of "Extra Might" get extra range and an extra bonus
376 * for the damage multiplier.
377 * Note that Bows of "Extra Shots" give an extra shot.
380 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
384 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
385 int tdam_base, tdis, thits, tmul;
387 int cur_dis, visible;
395 bool hit_body = FALSE;
397 GAME_TEXT o_name[MAX_NLEN];
399 u16b path_g[512]; /* For calcuration of path length */
401 int msec = delay_factor * delay_factor * delay_factor;
404 bool stick_to = FALSE;
406 /* Access the item (if in the pack) */
409 o_ptr = &shooter_ptr->inventory_list[item];
413 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
416 /* Sniper - Cannot shot a single arrow twice */
417 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
419 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
421 /* Use the proper number of shots */
422 thits = shooter_ptr->num_fire;
424 /* Use a base distance */
427 /* Base damage from thrown object plus launcher bonus */
428 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
430 /* Actually "fire" the object */
431 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
432 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
433 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
435 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
437 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
438 tmul = bow_tmul(j_ptr->sval);
440 /* Get extra "power" from "extra might" */
441 if (shooter_ptr->xtra_might) tmul++;
443 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
445 /* Boost the damage */
450 tdis = 13 + tmul / 80;
451 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
453 if (shooter_ptr->concent)
454 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
459 project_length = tdis + 1;
461 /* Get a direction (or cancel) */
462 if (!get_aim_dir(shooter_ptr, &dir))
464 free_turn(shooter_ptr);
466 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
468 /* need not to reset project_length (already did)*/
473 /* Predict the "target" location */
474 tx = shooter_ptr->x + 99 * ddx[dir];
475 ty = shooter_ptr->y + 99 * ddy[dir];
477 /* Check for "target request" */
478 if ((dir == 5) && target_okay(shooter_ptr))
484 /* Get projection path length */
485 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
487 project_length = 0; /* reset to default */
489 /* Don't shoot at my feet */
490 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
492 free_turn(shooter_ptr);
494 /* project_length is already reset to 0 */
500 /* Take a (partial) turn */
501 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
502 shooter_ptr->is_fired = TRUE;
504 /* Sniper - Difficult to shot twice at 1 turn */
505 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
507 /* Sniper - Repeat shooting when double shots */
508 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
511 /* Start at the player */
515 object_copy(q_ptr, o_ptr);
520 vary_item(shooter_ptr, item, -1);
523 handle_stuff(shooter_ptr);
528 /* The shot does not hit yet */
531 /* Travel until stopped */
532 for (cur_dis = 0; cur_dis <= tdis; )
536 /* Hack -- Stop at the target */
537 if ((y == ty) && (x == tx)) break;
539 /* Calculate the new location (see "project()") */
542 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
545 if (snipe_type == SP_KILL_WALL)
547 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
549 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
551 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
552 /* Forget the wall */
553 g_ptr->info &= ~(CAVE_MARK);
554 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
556 /* Destroy the wall */
557 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
564 /* Stopped by walls/doors */
565 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;
567 /* Advance the distance */
571 if (snipe_type == SP_LITE)
573 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
574 note_spot(shooter_ptr, ny, nx);
575 lite_spot(shooter_ptr, ny, nx);
578 /* The player can see the (on screen) missile */
579 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
581 char c = object_char(q_ptr);
582 byte a = object_attr(q_ptr);
584 /* Draw, Hilite, Fresh, Pause, Erase */
585 print_rel(shooter_ptr, c, a, ny, nx);
586 move_cursor_relative(ny, nx);
588 Term_xtra(TERM_XTRA_DELAY, msec);
589 lite_spot(shooter_ptr, ny, nx);
593 /* The player cannot see the missile */
596 /* Pause anyway, for consistancy */
597 Term_xtra(TERM_XTRA_DELAY, msec);
601 if (snipe_type == SP_KILL_TRAP)
603 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
604 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
608 if (snipe_type == SP_EVILNESS)
610 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
611 note_spot(shooter_ptr, ny, nx);
612 lite_spot(shooter_ptr, ny, nx);
618 /* Save the new location */
622 /* Monster here, Try to hit it */
623 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
625 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
627 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
628 monster_race *r_ptr = &r_info[m_ptr->r_idx];
630 /* Check the visibility */
633 /* Note the collision */
636 if (monster_csleep_remaining(m_ptr))
638 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
639 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
642 if ((r_ptr->level + 10) > shooter_ptr->lev)
644 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
645 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
648 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
649 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
650 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
651 else if (shooter_ptr->lev > 34) amount = 2;
652 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
653 shooter_ptr->update |= (PU_BONUS);
657 if (shooter_ptr->riding)
659 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
660 && ((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)
663 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
664 shooter_ptr->update |= (PU_BONUS);
668 /* Did we hit it (penalize range) */
669 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
672 int tdam = tdam_base;
674 /* Get extra damage from concentration */
675 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
677 /* Handle unseen monster */
680 /* Invisible monster */
681 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
684 /* Handle visible monster */
687 GAME_TEXT m_name[MAX_NLEN];
689 /* Get "the monster" or "it" */
690 monster_desc(shooter_ptr, m_name, m_ptr, 0);
692 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
696 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
697 health_track(shooter_ptr, c_mon_ptr->m_idx);
701 if (snipe_type == SP_NEEDLE)
703 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
704 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
706 GAME_TEXT m_name[MAX_NLEN];
708 /* Get "the monster" or "it" */
709 monster_desc(shooter_ptr, m_name, m_ptr, 0);
711 tdam = m_ptr->hp + 1;
712 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
718 /* Apply special damage */
719 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
720 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
722 /* No negative damage */
723 if (tdam < 0) tdam = 0;
725 /* Modify the damage */
726 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
729 msg_format_wizard(CHEAT_MONSTER,
730 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
731 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
734 if (snipe_type == SP_EXPLODE)
736 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
738 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
739 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
744 if (snipe_type == SP_HOLYNESS)
746 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
747 note_spot(shooter_ptr, ny, nx);
748 lite_spot(shooter_ptr, ny, nx);
751 /* Hit the monster, check for death */
752 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
761 if (object_is_fixed_artifact(q_ptr) &&
762 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
764 GAME_TEXT m_name[MAX_NLEN];
766 monster_desc(shooter_ptr, m_name, m_ptr, 0);
769 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
772 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
774 /* Anger the monster */
775 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
777 if (fear && m_ptr->ml)
779 GAME_TEXT m_name[MAX_NLEN];
781 monster_desc(shooter_ptr, m_name, m_ptr, 0);
782 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
785 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
788 if (snipe_type == SP_RUSH)
790 int n = randint1(5) + 3;
791 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
793 for (; cur_dis <= tdis; )
800 /* Calculate the new location (see "project()") */
801 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
803 /* Stopped by wilderness boundary */
804 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
806 /* Stopped by walls/doors */
807 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
809 /* Stopped by monsters */
810 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
812 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
813 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
818 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
820 lite_spot(shooter_ptr, ny, nx);
821 lite_spot(shooter_ptr, oy, ox);
824 Term_xtra(TERM_XTRA_DELAY, msec);
836 if (snipe_type == SP_PIERCE)
838 if (shooter_ptr->concent < 1) break;
839 shooter_ptr->concent--;
848 /* Chance of breakage (during attacks) */
849 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
853 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
854 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
855 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
859 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
860 if (object_is_fixed_artifact(q_ptr))
862 a_info[j_ptr->name1].cur_num = 0;
867 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
868 object_copy(o_ptr, q_ptr);
871 o_ptr->marked &= OM_TOUCHED;
873 /* Forget location */
874 o_ptr->iy = o_ptr->ix = 0;
876 /* Memorize monster */
877 o_ptr->held_m_idx = m_idx;
880 o_ptr->next_o_idx = m_ptr->hold_o_idx;
883 m_ptr->hold_o_idx = o_idx;
885 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
887 /* Drop (or break) near that location */
888 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
892 /* Drop (or break) near that location */
893 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
896 /* Sniper - Repeat shooting when double shots */
899 /* Sniper - Loose his/her concentration after any shot */
900 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
905 * @brief プレイヤーからモンスターへの射撃命中判定 /
906 * Determine if the player "hits" a monster (normal combat).
907 * @param chance 基本命中値
908 * @param m_ptr モンスターの構造体参照ポインタ
909 * @param vis 目標を視界に捕らえているならばTRUEを指定
910 * @param o_name メッセージ表示時のモンスター名
911 * @return 命中と判定された場合TRUEを返す
912 * @note Always miss 5%, always hit 5%, otherwise random.
914 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
918 monster_race *r_ptr = &r_info[m_ptr->r_idx];
920 /* Percentile dice */
923 /* Snipers with high-concentration reduce instant miss percentage.*/
924 k += shooter_ptr->concent;
926 /* Hack -- Instant miss or hit */
927 if (k <= 5) return FALSE;
928 if (k > 95) return TRUE;
930 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
931 if (one_in_(20)) return FALSE;
934 if (chance <= 0) return FALSE;
937 if (shooter_ptr->concent)
939 ac *= (8 - shooter_ptr->concent);
943 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) ac *= 3;
945 /* Invisible monsters are harder to hit */
946 if (!vis) chance = (chance + 1) / 2;
948 /* Power competes against armor */
949 if (randint0(chance) < (ac * 3 / 4))
951 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
953 GAME_TEXT m_name[MAX_NLEN];
954 monster_desc(shooter_ptr, m_name, m_ptr, 0);
955 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
968 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
969 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
970 * @param weight 矢弾の重量
971 * @param plus_ammo 矢弾の命中修正
972 * @param plus_bow 弓の命中修正
973 * @param dam 現在算出中のダメージ値
974 * @return クリティカル修正が入ったダメージ値
976 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
979 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
981 /* Extract "shot" power */
982 i = shooter_ptr->to_h_b + plus_ammo;
984 if (shooter_ptr->tval_ammo == TV_BOLT)
985 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
987 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
990 /* Snipers can shot more critically with crossbows */
991 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
992 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
994 /* Good bow makes more critical */
995 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
998 if (randint1(10000) <= i)
1000 k = weight * randint1(500);
1004 msg_print(_("手ごたえがあった!", "It was a good hit!"));
1009 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1014 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1026 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1027 * @param sval 射撃武器のアイテム副分類ID
1028 * @return 消費する基本エネルギー
1030 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1032 ENERGY energy = 10000;
1034 /* Analyze the launcher */
1037 /* Sling and ammo */
1044 /* Short Bow and Arrow */
1051 /* Long Bow and Arrow */
1058 /* Bow of irresponsiblity and Arrow */
1065 /* Light Crossbow and Bolt */
1072 /* Heavy Crossbow and Bolt */
1087 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1091 /* Analyze the launcher */
1094 /* Sling and ammo */
1101 /* Short Bow and Arrow */
1108 /* Long Bow and Arrow */
1115 /* Bow of irresponsiblity and Arrow */
1122 /* Light Crossbow and Bolt */
1129 /* Heavy Crossbow and Bolt */
1142 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1143 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1144 * @param plus_ammo 矢弾のダメージ修正
1145 * @param plus_bow 弓のダメージ修正
1147 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1149 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1152 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1154 /* Extract "shot" power */
1155 i = shooter_ptr->to_h_b + plus_ammo;
1157 if (shooter_ptr->tval_ammo == TV_BOLT)
1158 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1160 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1162 /* Snipers can shot more critically with crossbows */
1163 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1164 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1166 /* Good bow makes more critical */
1167 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1175 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1176 * @param weight 武器の重量
1177 * @param plus_ammo 矢弾のダメージ修正
1178 * @param plus_bow 弓のダメージ修正
1179 * @param dam 基本ダメージ量
1182 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1186 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1191 crit = MIN(500, 900 / weight);
1192 num += dam * 3 / 2 * crit;
1195 crit = MIN(500, 1350 / weight);
1197 num += dam * 2 * crit;
1203 num += dam * 3 * crit;
1209 num += (10000 - i) * dam;
1216 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1217 * @param shooter_ptr プレーヤーへの参照ポインタ
1218 * @param weight 武器の重量
1219 * @param plus 武器のダメージ修正
1221 * @param meichuu 命中値
1222 * @param dokubari 毒針処理か否か
1225 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1228 if (dokubari) return dam;
1230 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1236 if (k < 400) num += (2 * dam + 5) * (400 - k);
1237 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1238 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1239 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1240 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1243 if (shooter_ptr->pclass == CLASS_NINJA)
1246 num += (4444 - i) * dam;
1252 num += (5000 - i) * dam;