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/grid.h"
15 #include "inventory/inventory-object.h"
16 #include "inventory/inventory-slot-types.h"
17 #include "io/cursor.h"
18 #include "io/screen-util.h"
19 #include "io/targeting.h"
20 #include "main/sound-definitions-table.h"
21 #include "main/sound-of-music.h"
22 #include "mind/mind-sniper.h"
23 #include "mind/snipe-types.h"
24 #include "monster-floor/monster-death.h"
25 #include "monster-floor/monster-move.h"
26 #include "monster-race/monster-race.h"
27 #include "monster-race/race-flags-resistance.h"
28 #include "monster-race/race-flags1.h"
29 #include "monster-race/race-flags2.h"
30 #include "monster-race/race-flags3.h"
31 #include "monster-race/race-flags7.h"
32 #include "monster-race/race-indice-types.h"
33 #include "monster/monster-describer.h"
34 #include "monster/monster-info.h"
35 #include "monster/monster-status.h"
36 #include "monster/monster-update.h"
37 #include "object-enchant/artifact.h"
38 #include "object-enchant/tr-types.h"
39 #include "object-hook/hook-enchant.h"
40 #include "object/object-broken.h"
41 #include "object/object-flags.h"
42 #include "object/object-generator.h"
43 #include "object/object-info.h"
44 #include "object/object-kind.h"
45 #include "object/object-mark-types.h"
46 #include "player/avatar.h"
47 #include "player/player-class.h"
48 #include "player/player-personalities-types.h"
49 #include "player/player-skill.h"
50 #include "player/player-status.h"
51 #include "spell/process-effect.h"
52 #include "spell/spell-types.h"
53 #include "sv-definition/sv-bow-types.h"
54 #include "util/bit-flags-calculator.h"
55 #include "view/display-messages.h"
56 #include "wizard/wizard-messages.h"
57 #include "world/world-object.h"
60 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
61 * Determines the odds of an object breaking when thrown at a monster
62 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
63 * @param tdam 計算途中のダメージ量
64 * @param m_ptr 目標モンスターの構造体参照ポインタ
65 * @return スレイ倍率をかけたダメージ量
67 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)
71 monster_race *r_ptr = &r_info[m_ptr->r_idx];
73 BIT_FLAGS flgs[TR_FLAG_SIZE];
74 object_flags(sniper_ptr, o_ptr, flgs);
76 /* Some "weapons" and "ammo" do extra damage */
77 switch (o_ptr->tval) {
81 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL)) {
82 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
83 r_ptr->r_flags3 |= RF3_ANIMAL;
89 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL)) {
90 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
91 r_ptr->r_flags3 |= RF3_ANIMAL;
97 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL)) {
98 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
99 r_ptr->r_flags3 |= RF3_EVIL;
105 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL)) {
106 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
107 r_ptr->r_flags3 |= RF3_EVIL;
113 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN)) {
114 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
115 r_ptr->r_flags2 |= RF2_HUMAN;
121 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN)) {
122 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
123 r_ptr->r_flags2 |= RF2_HUMAN;
129 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD)) {
130 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
131 r_ptr->r_flags3 |= RF3_UNDEAD;
137 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD)) {
138 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
139 r_ptr->r_flags3 |= RF3_UNDEAD;
145 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON)) {
146 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
147 r_ptr->r_flags3 |= RF3_DEMON;
153 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON)) {
154 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
155 r_ptr->r_flags3 |= RF3_DEMON;
161 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC)) {
162 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
163 r_ptr->r_flags3 |= RF3_ORC;
169 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC)) {
170 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
171 r_ptr->r_flags3 |= RF3_ORC;
177 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL)) {
178 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
179 r_ptr->r_flags3 |= RF3_TROLL;
186 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL)) {
187 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
188 r_ptr->r_flags3 |= RF3_TROLL;
194 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT)) {
195 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
196 r_ptr->r_flags3 |= RF3_GIANT;
202 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT)) {
203 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
204 r_ptr->r_flags3 |= RF3_GIANT;
210 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON)) {
211 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
212 r_ptr->r_flags3 |= RF3_DRAGON;
218 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON)) {
219 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
220 r_ptr->r_flags3 |= RF3_DRAGON;
224 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) && (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
228 if (have_flag(flgs, TR_BRAND_ACID)) {
229 /* Notice immunity */
230 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK) {
231 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
232 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
240 if (have_flag(flgs, TR_BRAND_ELEC)) {
241 /* Notice immunity */
242 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK) {
243 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
244 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
252 if (have_flag(flgs, TR_BRAND_FIRE)) {
253 /* Notice immunity */
254 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK) {
255 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
256 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
259 /* Otherwise, take the damage */
261 if (r_ptr->flags3 & RF3_HURT_FIRE) {
264 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
265 r_ptr->r_flags3 |= RF3_HURT_FIRE;
267 } else if (mult < 17)
272 if (have_flag(flgs, TR_BRAND_COLD)) {
273 /* Notice immunity */
274 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK) {
275 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
276 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
279 /* Otherwise, take the damage */
281 if (r_ptr->flags3 & RF3_HURT_COLD) {
284 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
285 r_ptr->r_flags3 |= RF3_HURT_COLD;
287 } else if (mult < 17)
292 if (have_flag(flgs, TR_BRAND_POIS)) {
293 /* Notice immunity */
294 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK) {
295 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
296 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
299 /* Otherwise, take the damage */
306 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30))) {
307 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
308 sniper_ptr->redraw |= (PR_MANA);
317 mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
319 /* Return the total damage */
320 return (tdam * mult / 10);
325 * Fire an object from the pack or floor.
326 * @param item 射撃するオブジェクトの所持ID
327 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
331 * You may only fire items that "match" your missile launcher.
332 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
333 * See "calc_bonuses()" for more calculations and such.
334 * Note that "firing" a missile is MUCH better than "throwing" it.
335 * Note: "unseen" monsters are very hard to hit.
336 * Objects are more likely to break if they "attempt" to hit a monster.
337 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
338 * The "extra shot" code works by decreasing the amount of energy
339 * required to make each shot, spreading the shots out over time.
340 * Note that when firing missiles, the launcher multiplier is applied
341 * after all the bonuses are added in, making multipliers very useful.
342 * Note that Bows of "Extra Might" get extra range and an extra bonus
343 * for the damage multiplier.
344 * Note that Bows of "Extra Shots" give an extra shot.
347 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
351 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
352 int tdam_base, tdis, thits, tmul;
354 int cur_dis, visible;
362 bool hit_body = FALSE;
364 GAME_TEXT o_name[MAX_NLEN];
366 u16b path_g[512]; /* For calcuration of path length */
368 int msec = delay_factor * delay_factor * delay_factor;
371 bool stick_to = FALSE;
373 /* Access the item (if in the pack) */
375 o_ptr = &shooter_ptr->inventory_list[item];
377 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
380 /* Sniper - Cannot shot a single arrow twice */
381 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2))
382 snipe_type = SP_NONE;
384 describe_flavor(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
386 /* Use the proper number of shots */
387 thits = shooter_ptr->num_fire;
389 /* Use a base distance */
392 /* Base damage from thrown object plus launcher bonus */
393 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
395 /* Actually "fire" the object */
396 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
397 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
398 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
400 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
402 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
403 tmul = bow_tmul(j_ptr->sval);
405 /* Get extra "power" from "extra might" */
406 if (shooter_ptr->xtra_might)
409 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
411 /* Boost the damage */
416 tdis = 13 + tmul / 80;
417 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW)) {
418 if (shooter_ptr->concent)
419 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
424 project_length = tdis + 1;
426 /* Get a direction (or cancel) */
427 if (!get_aim_dir(shooter_ptr, &dir)) {
428 free_turn(shooter_ptr);
430 if (snipe_type == SP_AWAY)
431 snipe_type = SP_NONE;
433 /* need not to reset project_length (already did)*/
438 /* Predict the "target" location */
439 tx = shooter_ptr->x + 99 * ddx[dir];
440 ty = shooter_ptr->y + 99 * ddy[dir];
442 /* Check for "target request" */
443 if ((dir == 5) && target_okay(shooter_ptr)) {
448 /* Get projection path length */
449 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
451 project_length = 0; /* reset to default */
453 /* Don't shoot at my feet */
454 if (tx == shooter_ptr->x && ty == shooter_ptr->y) {
455 free_turn(shooter_ptr);
457 /* project_length is already reset to 0 */
462 /* Take a (partial) turn */
463 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
464 shooter_ptr->is_fired = TRUE;
466 /* Sniper - Difficult to shot twice at 1 turn */
467 if (snipe_type == SP_DOUBLE)
468 shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
470 /* Sniper - Repeat shooting when double shots */
471 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++) {
473 /* Start at the player */
477 object_copy(q_ptr, o_ptr);
482 vary_item(shooter_ptr, item, -1);
485 handle_stuff(shooter_ptr);
490 /* The shot does not hit yet */
493 /* Travel until stopped */
494 for (cur_dis = 0; cur_dis <= tdis;) {
497 /* Hack -- Stop at the target */
498 if ((y == ty) && (x == tx))
501 /* Calculate the new location (see "project()") */
504 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
507 if (snipe_type == SP_KILL_WALL) {
508 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
510 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx) {
511 if (g_ptr->info & (CAVE_MARK))
512 msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
513 /* Forget the wall */
514 g_ptr->info &= ~(CAVE_MARK);
515 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
517 /* Destroy the wall */
518 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
525 /* Stopped by walls/doors */
526 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)
529 /* Advance the distance */
533 if (snipe_type == SP_LITE) {
534 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
535 note_spot(shooter_ptr, ny, nx);
536 lite_spot(shooter_ptr, ny, nx);
539 /* The player can see the (on screen) missile */
540 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx)) {
541 SYMBOL_CODE c = object_char(q_ptr);
542 byte a = object_attr(q_ptr);
544 /* Draw, Hilite, Fresh, Pause, Erase */
545 print_rel(shooter_ptr, c, a, ny, nx);
546 move_cursor_relative(ny, nx);
548 Term_xtra(TERM_XTRA_DELAY, msec);
549 lite_spot(shooter_ptr, ny, nx);
553 /* The player cannot see the missile */
555 /* Pause anyway, for consistancy */
556 Term_xtra(TERM_XTRA_DELAY, msec);
560 if (snipe_type == SP_KILL_TRAP) {
561 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP, (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
565 if (snipe_type == SP_EVILNESS) {
566 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
567 note_spot(shooter_ptr, ny, nx);
568 lite_spot(shooter_ptr, ny, nx);
574 /* Save the new location */
578 /* Monster here, Try to hit it */
579 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
580 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
582 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
583 monster_race *r_ptr = &r_info[m_ptr->r_idx];
585 /* Check the visibility */
588 /* Note the collision */
591 if (monster_csleep_remaining(m_ptr)) {
592 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5))
593 chg_virtue(shooter_ptr, V_COMPASSION, -1);
594 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5))
595 chg_virtue(shooter_ptr, V_HONOUR, -1);
598 if ((r_ptr->level + 10) > shooter_ptr->lev) {
599 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
600 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval]) {
602 if (now_exp < WEAPON_EXP_BEGINNER)
604 else if (now_exp < WEAPON_EXP_SKILLED)
606 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19))
608 else if (shooter_ptr->lev > 34)
610 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
611 shooter_ptr->update |= (PU_BONUS);
615 if (shooter_ptr->riding) {
616 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
617 && ((shooter_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200
618 < r_info[shooter_ptr->current_floor_ptr->m_list[shooter_ptr->riding].r_idx].level)
620 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
621 shooter_ptr->update |= (PU_BONUS);
625 /* Did we hit it (penalize range) */
626 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name)) {
628 int tdam = tdam_base;
630 /* Get extra damage from concentration */
631 if (shooter_ptr->concent)
632 tdam = boost_concentration_damage(shooter_ptr, tdam);
634 /* Handle unseen monster */
636 /* Invisible monster */
637 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
640 /* Handle visible monster */
642 GAME_TEXT m_name[MAX_NLEN];
644 /* Get "the monster" or "it" */
645 monster_desc(shooter_ptr, m_name, m_ptr, 0);
647 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
650 if (!shooter_ptr->image)
651 monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
652 health_track(shooter_ptr, c_mon_ptr->m_idx);
656 if (snipe_type == SP_NEEDLE) {
657 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1) && !(r_ptr->flags1 & RF1_UNIQUE)
658 && !(r_ptr->flags7 & RF7_UNIQUE2)) {
659 GAME_TEXT m_name[MAX_NLEN];
661 /* Get "the monster" or "it" */
662 monster_desc(shooter_ptr, m_name, m_ptr, 0);
664 tdam = m_ptr->hp + 1;
665 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
669 /* Apply special damage */
670 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
671 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
673 /* No negative damage */
677 /* Modify the damage */
678 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
681 msg_format_wizard(shooter_ptr, CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"), tdam,
682 m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
685 if (snipe_type == SP_EXPLODE) {
686 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
688 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
689 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
694 if (snipe_type == SP_HOLYNESS) {
695 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
696 note_spot(shooter_ptr, ny, nx);
697 lite_spot(shooter_ptr, ny, nx);
700 /* Hit the monster, check for death */
701 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr)))) {
708 if (object_is_fixed_artifact(q_ptr) && (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0)) {
709 GAME_TEXT m_name[MAX_NLEN];
711 monster_desc(shooter_ptr, m_name, m_ptr, 0);
714 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
717 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
719 /* Anger the monster */
721 anger_monster(shooter_ptr, m_ptr);
723 if (fear && m_ptr->ml) {
724 GAME_TEXT m_name[MAX_NLEN];
726 monster_desc(shooter_ptr, m_name, m_ptr, 0);
727 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
730 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
733 if (snipe_type == SP_RUSH) {
734 int n = randint1(5) + 3;
735 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
737 for (; cur_dis <= tdis;) {
744 /* Calculate the new location (see "project()") */
745 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
747 /* Stopped by wilderness boundary */
748 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx))
751 /* Stopped by walls/doors */
752 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0))
755 /* Stopped by monsters */
756 if (!is_cave_empty_bold(shooter_ptr, ny, nx))
759 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
760 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
765 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
767 lite_spot(shooter_ptr, ny, nx);
768 lite_spot(shooter_ptr, oy, ox);
771 Term_xtra(TERM_XTRA_DELAY, msec);
783 if (snipe_type == SP_PIERCE) {
784 if (shooter_ptr->concent < 1)
786 shooter_ptr->concent--;
795 /* Chance of breakage (during attacks) */
796 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
799 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
800 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
801 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
804 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
805 if (object_is_fixed_artifact(q_ptr)) {
806 a_info[j_ptr->name1].cur_num = 0;
811 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
812 object_copy(o_ptr, q_ptr);
815 o_ptr->marked &= OM_TOUCHED;
817 /* Forget location */
818 o_ptr->iy = o_ptr->ix = 0;
820 /* Memorize monster */
821 o_ptr->held_m_idx = m_idx;
824 o_ptr->next_o_idx = m_ptr->hold_o_idx;
827 m_ptr->hold_o_idx = o_idx;
828 } else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT)) {
829 /* Drop (or break) near that location */
830 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
832 /* Drop (or break) near that location */
833 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
836 /* Sniper - Repeat shooting when double shots */
839 /* Sniper - Loose his/her concentration after any shot */
840 if (shooter_ptr->concent)
841 reset_concentration(shooter_ptr, FALSE);
845 * @brief プレイヤーからモンスターへの射撃命中判定 /
846 * Determine if the player "hits" a monster (normal combat).
847 * @param chance 基本命中値
848 * @param m_ptr モンスターの構造体参照ポインタ
849 * @param vis 目標を視界に捕らえているならばTRUEを指定
850 * @param o_name メッセージ表示時のモンスター名
851 * @return 命中と判定された場合TRUEを返す
852 * @note Always miss 5%, always hit 5%, otherwise random.
854 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char *o_name)
858 monster_race *r_ptr = &r_info[m_ptr->r_idx];
860 /* Percentile dice */
863 /* Snipers with high-concentration reduce instant miss percentage.*/
864 k += shooter_ptr->concent;
866 /* Hack -- Instant miss or hit */
872 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
881 if (shooter_ptr->concent) {
882 ac *= (8 - shooter_ptr->concent);
886 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
889 /* Invisible monsters are harder to hit */
891 chance = (chance + 1) / 2;
893 /* Power competes against armor */
894 if (randint0(chance) < (ac * 3 / 4)) {
895 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) {
896 GAME_TEXT m_name[MAX_NLEN];
897 monster_desc(shooter_ptr, m_name, m_ptr, 0);
898 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
908 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
909 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
910 * @param weight 矢弾の重量
911 * @param plus_ammo 矢弾の命中修正
912 * @param plus_bow 弓の命中修正
913 * @param dam 現在算出中のダメージ値
914 * @return クリティカル修正が入ったダメージ値
916 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
919 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
921 /* Extract "shot" power */
922 i = shooter_ptr->to_h_b + plus_ammo;
924 if (shooter_ptr->tval_ammo == TV_BOLT)
925 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
927 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
929 /* Snipers can shot more critically with crossbows */
930 if (shooter_ptr->concent)
931 i += ((i * shooter_ptr->concent) / 5);
932 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT))
935 /* Good bow makes more critical */
936 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
939 if (randint1(10000) <= i) {
940 k = weight * randint1(500);
943 msg_print(_("手ごたえがあった!", "It was a good hit!"));
945 } else if (k < 1350) {
946 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
949 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
958 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
959 * @param sval 射撃武器のアイテム副分類ID
960 * @return 消費する基本エネルギー
962 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
964 ENERGY energy = 10000;
966 /* Analyze the launcher */
974 /* Short Bow and Arrow */
980 /* Long Bow and Arrow */
986 /* Bow of irresponsiblity and Arrow */
987 case SV_NAMAKE_BOW: {
992 /* Light Crossbow and Bolt */
993 case SV_LIGHT_XBOW: {
998 /* Heavy Crossbow and Bolt */
999 case SV_HEAVY_XBOW: {
1011 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1015 /* Analyze the launcher */
1017 /* Sling and ammo */
1023 /* Short Bow and Arrow */
1024 case SV_SHORT_BOW: {
1029 /* Long Bow and Arrow */
1035 /* Bow of irresponsiblity and Arrow */
1036 case SV_NAMAKE_BOW: {
1041 /* Light Crossbow and Bolt */
1042 case SV_LIGHT_XBOW: {
1047 /* Heavy Crossbow and Bolt */
1048 case SV_HEAVY_XBOW: {
1058 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1059 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1060 * @param plus_ammo 矢弾のダメージ修正
1061 * @param plus_bow 弓のダメージ修正
1063 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1065 HIT_POINT calc_crit_ratio_shot(player_type *shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1068 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1070 /* Extract "shot" power */
1071 i = shooter_ptr->to_h_b + plus_ammo;
1073 if (shooter_ptr->tval_ammo == TV_BOLT)
1074 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1076 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1078 /* Snipers can shot more critically with crossbows */
1079 if (shooter_ptr->concent)
1080 i += ((i * shooter_ptr->concent) / 5);
1081 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT))
1084 /* Good bow makes more critical */
1085 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1094 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1095 * @param weight 武器の重量
1096 * @param plus_ammo 矢弾のダメージ修正
1097 * @param plus_bow 弓のダメージ修正
1098 * @param dam 基本ダメージ量
1101 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1105 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1110 crit = MIN(500, 900 / weight);
1111 num += dam * 3 / 2 * crit;
1114 crit = MIN(500, 1350 / weight);
1116 num += dam * 2 * crit;
1121 num += dam * 3 * crit;
1127 num += (10000 - i) * dam;
1134 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1135 * @param shooter_ptr プレーヤーへの参照ポインタ
1136 * @param weight 武器の重量
1137 * @param plus 武器のダメージ修正
1139 * @param meichuu 命中値
1140 * @param dokubari 毒針処理か否か
1143 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1149 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1157 num += (2 * dam + 5) * (400 - k);
1159 num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1160 if (k > (700 - 650) && k < 900)
1161 num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1162 if (k > (900 - 650) && k < 1300)
1163 num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1164 if (k > (1300 - 650))
1165 num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1168 if (shooter_ptr->pclass == CLASS_NINJA) {
1170 num += (4444 - i) * dam;
1174 num += (5000 - i) * dam;