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 "floor/floor-object.h"
9 #include "game-option/cheat-types.h"
10 #include "game-option/special-options.h"
11 #include "grid/feature.h"
12 #include "grid/grid.h"
13 #include "inventory/inventory-object.h"
14 #include "inventory/inventory-slot-types.h"
15 #include "io/cursor.h"
16 #include "io/screen-util.h"
17 #include "io/targeting.h"
18 #include "main/sound-definitions-table.h"
19 #include "main/sound-of-music.h"
20 #include "mind/mind-sniper.h"
21 #include "mind/snipe-types.h"
22 #include "monster-floor/monster-death.h"
23 #include "monster-floor/monster-move.h"
24 #include "monster-race/monster-race.h"
25 #include "monster-race/race-flags-resistance.h"
26 #include "monster-race/race-flags1.h"
27 #include "monster-race/race-flags2.h"
28 #include "monster-race/race-flags3.h"
29 #include "monster-race/race-flags7.h"
30 #include "monster-race/race-indice-types.h"
31 #include "monster/monster-describer.h"
32 #include "monster/monster-info.h"
33 #include "monster/monster-status.h"
34 #include "monster/monster-update.h"
35 #include "object-enchant/artifact.h"
36 #include "object-enchant/tr-types.h"
37 #include "object-hook/hook-enchant.h"
38 #include "object/object-broken.h"
39 #include "object/object-flags.h"
40 #include "object/object-flavor.h"
41 #include "object/object-generator.h"
42 #include "object/object-info.h"
43 #include "object/object-kind.h"
44 #include "object/object-mark-types.h"
45 #include "player/avatar.h"
46 #include "player/player-class.h"
47 #include "player/player-personalities-types.h"
48 #include "player/player-skill.h"
49 #include "player/player-status.h"
50 #include "spell/process-effect.h"
51 #include "spell/spell-types.h"
52 #include "sv-definition/sv-bow-types.h"
53 #include "util/bit-flags-calculator.h"
54 #include "view/display-messages.h"
55 #include "wizard/wizard-messages.h"
56 #include "world/world-object.h"
59 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
60 * Determines the odds of an object breaking when thrown at a monster
61 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
62 * @param tdam 計算途中のダメージ量
63 * @param m_ptr 目標モンスターの構造体参照ポインタ
64 * @return スレイ倍率をかけたダメージ量
66 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)
70 monster_race *r_ptr = &r_info[m_ptr->r_idx];
72 BIT_FLAGS flgs[TR_FLAG_SIZE];
73 object_flags(sniper_ptr, o_ptr, flgs);
75 /* Some "weapons" and "ammo" do extra damage */
82 if ((have_flag(flgs, TR_SLAY_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 < 17) mult = 17;
91 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
93 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
95 r_ptr->r_flags3 |= RF3_ANIMAL;
97 if (mult < 27) mult = 27;
100 if ((have_flag(flgs, TR_SLAY_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 < 15) mult = 15;
109 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
111 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
113 r_ptr->r_flags3 |= RF3_EVIL;
115 if (mult < 25) mult = 25;
118 if ((have_flag(flgs, TR_SLAY_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 < 17) mult = 17;
127 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
129 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
131 r_ptr->r_flags2 |= RF2_HUMAN;
133 if (mult < 27) mult = 27;
136 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
145 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
147 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
149 r_ptr->r_flags3 |= RF3_UNDEAD;
151 if (mult < 30) mult = 30;
154 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
163 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
165 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
167 r_ptr->r_flags3 |= RF3_DEMON;
169 if (mult < 30) mult = 30;
172 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
181 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
183 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
185 r_ptr->r_flags3 |= RF3_ORC;
187 if (mult < 30) mult = 30;
190 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
192 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
194 r_ptr->r_flags3 |= RF3_TROLL;
197 if (mult < 20) mult = 20;
200 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
202 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
204 r_ptr->r_flags3 |= RF3_TROLL;
206 if (mult < 30) mult = 30;
209 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
218 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
220 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
222 r_ptr->r_flags3 |= RF3_GIANT;
224 if (mult < 30) mult = 30;
227 if ((have_flag(flgs, TR_SLAY_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 < 20) mult = 20;
236 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
238 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
240 r_ptr->r_flags3 |= RF3_DRAGON;
242 if (mult < 30) mult = 30;
243 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
244 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
248 if (have_flag(flgs, TR_BRAND_ACID))
250 /* Notice immunity */
251 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
253 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
255 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
260 if (mult < 17) mult = 17;
264 if (have_flag(flgs, TR_BRAND_ELEC))
266 /* Notice immunity */
267 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
269 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
271 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
276 if (mult < 17) mult = 17;
280 if (have_flag(flgs, TR_BRAND_FIRE))
282 /* Notice immunity */
283 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
285 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
287 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
290 /* Otherwise, take the damage */
293 if (r_ptr->flags3 & RF3_HURT_FIRE)
295 if (mult < 25) mult = 25;
296 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
298 r_ptr->r_flags3 |= RF3_HURT_FIRE;
301 else if (mult < 17) mult = 17;
305 if (have_flag(flgs, TR_BRAND_COLD))
307 /* Notice immunity */
308 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
310 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
312 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
315 /* Otherwise, take the damage */
318 if (r_ptr->flags3 & RF3_HURT_COLD)
320 if (mult < 25) mult = 25;
321 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
323 r_ptr->r_flags3 |= RF3_HURT_COLD;
326 else if (mult < 17) mult = 17;
330 if (have_flag(flgs, TR_BRAND_POIS))
332 /* Notice immunity */
333 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
335 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
337 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
340 /* Otherwise, take the damage */
343 if (mult < 17) mult = 17;
347 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
349 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
350 sniper_ptr->redraw |= (PR_MANA);
358 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
360 /* Return the total damage */
361 return (tdam * mult / 10);
367 * Fire an object from the pack or floor.
368 * @param item 射撃するオブジェクトの所持ID
369 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
373 * You may only fire items that "match" your missile launcher.
374 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
375 * See "calc_bonuses()" for more calculations and such.
376 * Note that "firing" a missile is MUCH better than "throwing" it.
377 * Note: "unseen" monsters are very hard to hit.
378 * Objects are more likely to break if they "attempt" to hit a monster.
379 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
380 * The "extra shot" code works by decreasing the amount of energy
381 * required to make each shot, spreading the shots out over time.
382 * Note that when firing missiles, the launcher multiplier is applied
383 * after all the bonuses are added in, making multipliers very useful.
384 * Note that Bows of "Extra Might" get extra range and an extra bonus
385 * for the damage multiplier.
386 * Note that Bows of "Extra Shots" give an extra shot.
389 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
393 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
394 int tdam_base, tdis, thits, tmul;
396 int cur_dis, visible;
404 bool hit_body = FALSE;
406 GAME_TEXT o_name[MAX_NLEN];
408 u16b path_g[512]; /* For calcuration of path length */
410 int msec = delay_factor * delay_factor * delay_factor;
413 bool stick_to = FALSE;
415 /* Access the item (if in the pack) */
418 o_ptr = &shooter_ptr->inventory_list[item];
422 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
425 /* Sniper - Cannot shot a single arrow twice */
426 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
428 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
430 /* Use the proper number of shots */
431 thits = shooter_ptr->num_fire;
433 /* Use a base distance */
436 /* Base damage from thrown object plus launcher bonus */
437 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
439 /* Actually "fire" the object */
440 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
441 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
442 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
444 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
446 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
447 tmul = bow_tmul(j_ptr->sval);
449 /* Get extra "power" from "extra might" */
450 if (shooter_ptr->xtra_might) tmul++;
452 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
454 /* Boost the damage */
459 tdis = 13 + tmul / 80;
460 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
462 if (shooter_ptr->concent)
463 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
468 project_length = tdis + 1;
470 /* Get a direction (or cancel) */
471 if (!get_aim_dir(shooter_ptr, &dir))
473 free_turn(shooter_ptr);
475 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
477 /* need not to reset project_length (already did)*/
482 /* Predict the "target" location */
483 tx = shooter_ptr->x + 99 * ddx[dir];
484 ty = shooter_ptr->y + 99 * ddy[dir];
486 /* Check for "target request" */
487 if ((dir == 5) && target_okay(shooter_ptr))
493 /* Get projection path length */
494 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
496 project_length = 0; /* reset to default */
498 /* Don't shoot at my feet */
499 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
501 free_turn(shooter_ptr);
503 /* project_length is already reset to 0 */
509 /* Take a (partial) turn */
510 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
511 shooter_ptr->is_fired = TRUE;
513 /* Sniper - Difficult to shot twice at 1 turn */
514 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
516 /* Sniper - Repeat shooting when double shots */
517 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
520 /* Start at the player */
524 object_copy(q_ptr, o_ptr);
529 vary_item(shooter_ptr, item, -1);
532 handle_stuff(shooter_ptr);
537 /* The shot does not hit yet */
540 /* Travel until stopped */
541 for (cur_dis = 0; cur_dis <= tdis; )
545 /* Hack -- Stop at the target */
546 if ((y == ty) && (x == tx)) break;
548 /* Calculate the new location (see "project()") */
551 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
554 if (snipe_type == SP_KILL_WALL)
556 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
558 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
560 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
561 /* Forget the wall */
562 g_ptr->info &= ~(CAVE_MARK);
563 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
565 /* Destroy the wall */
566 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
573 /* Stopped by walls/doors */
574 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;
576 /* Advance the distance */
580 if (snipe_type == SP_LITE)
582 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
583 note_spot(shooter_ptr, ny, nx);
584 lite_spot(shooter_ptr, ny, nx);
587 /* The player can see the (on screen) missile */
588 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
590 SYMBOL_CODE c = object_char(q_ptr);
591 byte a = object_attr(q_ptr);
593 /* Draw, Hilite, Fresh, Pause, Erase */
594 print_rel(shooter_ptr, c, a, ny, nx);
595 move_cursor_relative(ny, nx);
597 Term_xtra(TERM_XTRA_DELAY, msec);
598 lite_spot(shooter_ptr, ny, nx);
602 /* The player cannot see the missile */
605 /* Pause anyway, for consistancy */
606 Term_xtra(TERM_XTRA_DELAY, msec);
610 if (snipe_type == SP_KILL_TRAP)
612 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
613 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
617 if (snipe_type == SP_EVILNESS)
619 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
620 note_spot(shooter_ptr, ny, nx);
621 lite_spot(shooter_ptr, ny, nx);
627 /* Save the new location */
631 /* Monster here, Try to hit it */
632 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
634 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
636 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
637 monster_race *r_ptr = &r_info[m_ptr->r_idx];
639 /* Check the visibility */
642 /* Note the collision */
645 if (monster_csleep_remaining(m_ptr))
647 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
648 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
651 if ((r_ptr->level + 10) > shooter_ptr->lev)
653 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
654 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
657 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
658 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
659 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
660 else if (shooter_ptr->lev > 34) amount = 2;
661 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
662 shooter_ptr->update |= (PU_BONUS);
666 if (shooter_ptr->riding)
668 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
669 && ((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)
672 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
673 shooter_ptr->update |= (PU_BONUS);
677 /* Did we hit it (penalize range) */
678 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
681 int tdam = tdam_base;
683 /* Get extra damage from concentration */
684 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
686 /* Handle unseen monster */
689 /* Invisible monster */
690 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
693 /* Handle visible monster */
696 GAME_TEXT m_name[MAX_NLEN];
698 /* Get "the monster" or "it" */
699 monster_desc(shooter_ptr, m_name, m_ptr, 0);
701 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
705 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
706 health_track(shooter_ptr, c_mon_ptr->m_idx);
710 if (snipe_type == SP_NEEDLE)
712 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
713 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
715 GAME_TEXT m_name[MAX_NLEN];
717 /* Get "the monster" or "it" */
718 monster_desc(shooter_ptr, m_name, m_ptr, 0);
720 tdam = m_ptr->hp + 1;
721 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
727 /* Apply special damage */
728 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
729 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
731 /* No negative damage */
732 if (tdam < 0) tdam = 0;
734 /* Modify the damage */
735 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
738 msg_format_wizard(shooter_ptr, CHEAT_MONSTER,
739 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
740 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
743 if (snipe_type == SP_EXPLODE)
745 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
747 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
748 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
753 if (snipe_type == SP_HOLYNESS)
755 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
756 note_spot(shooter_ptr, ny, nx);
757 lite_spot(shooter_ptr, ny, nx);
760 /* Hit the monster, check for death */
761 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
770 if (object_is_fixed_artifact(q_ptr) &&
771 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
773 GAME_TEXT m_name[MAX_NLEN];
775 monster_desc(shooter_ptr, m_name, m_ptr, 0);
778 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
781 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
783 /* Anger the monster */
784 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
786 if (fear && m_ptr->ml)
788 GAME_TEXT m_name[MAX_NLEN];
790 monster_desc(shooter_ptr, m_name, m_ptr, 0);
791 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
794 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
797 if (snipe_type == SP_RUSH)
799 int n = randint1(5) + 3;
800 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
802 for (; cur_dis <= tdis; )
809 /* Calculate the new location (see "project()") */
810 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
812 /* Stopped by wilderness boundary */
813 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
815 /* Stopped by walls/doors */
816 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
818 /* Stopped by monsters */
819 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
821 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
822 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
827 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
829 lite_spot(shooter_ptr, ny, nx);
830 lite_spot(shooter_ptr, oy, ox);
833 Term_xtra(TERM_XTRA_DELAY, msec);
845 if (snipe_type == SP_PIERCE)
847 if (shooter_ptr->concent < 1) break;
848 shooter_ptr->concent--;
857 /* Chance of breakage (during attacks) */
858 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
862 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
863 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
864 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
868 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
869 if (object_is_fixed_artifact(q_ptr))
871 a_info[j_ptr->name1].cur_num = 0;
876 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
877 object_copy(o_ptr, q_ptr);
880 o_ptr->marked &= OM_TOUCHED;
882 /* Forget location */
883 o_ptr->iy = o_ptr->ix = 0;
885 /* Memorize monster */
886 o_ptr->held_m_idx = m_idx;
889 o_ptr->next_o_idx = m_ptr->hold_o_idx;
892 m_ptr->hold_o_idx = o_idx;
894 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
896 /* Drop (or break) near that location */
897 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
901 /* Drop (or break) near that location */
902 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
905 /* Sniper - Repeat shooting when double shots */
908 /* Sniper - Loose his/her concentration after any shot */
909 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
914 * @brief プレイヤーからモンスターへの射撃命中判定 /
915 * Determine if the player "hits" a monster (normal combat).
916 * @param chance 基本命中値
917 * @param m_ptr モンスターの構造体参照ポインタ
918 * @param vis 目標を視界に捕らえているならばTRUEを指定
919 * @param o_name メッセージ表示時のモンスター名
920 * @return 命中と判定された場合TRUEを返す
921 * @note Always miss 5%, always hit 5%, otherwise random.
923 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
927 monster_race *r_ptr = &r_info[m_ptr->r_idx];
929 /* Percentile dice */
932 /* Snipers with high-concentration reduce instant miss percentage.*/
933 k += shooter_ptr->concent;
935 /* Hack -- Instant miss or hit */
936 if (k <= 5) return FALSE;
937 if (k > 95) return TRUE;
939 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
940 if (one_in_(20)) return FALSE;
943 if (chance <= 0) return FALSE;
946 if (shooter_ptr->concent)
948 ac *= (8 - shooter_ptr->concent);
952 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) ac *= 3;
954 /* Invisible monsters are harder to hit */
955 if (!vis) chance = (chance + 1) / 2;
957 /* Power competes against armor */
958 if (randint0(chance) < (ac * 3 / 4))
960 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
962 GAME_TEXT m_name[MAX_NLEN];
963 monster_desc(shooter_ptr, m_name, m_ptr, 0);
964 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
977 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
978 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
979 * @param weight 矢弾の重量
980 * @param plus_ammo 矢弾の命中修正
981 * @param plus_bow 弓の命中修正
982 * @param dam 現在算出中のダメージ値
983 * @return クリティカル修正が入ったダメージ値
985 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
988 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
990 /* Extract "shot" power */
991 i = shooter_ptr->to_h_b + plus_ammo;
993 if (shooter_ptr->tval_ammo == TV_BOLT)
994 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
996 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
999 /* Snipers can shot more critically with crossbows */
1000 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1001 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1003 /* Good bow makes more critical */
1004 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1007 if (randint1(10000) <= i)
1009 k = weight * randint1(500);
1013 msg_print(_("手ごたえがあった!", "It was a good hit!"));
1018 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1023 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1035 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1036 * @param sval 射撃武器のアイテム副分類ID
1037 * @return 消費する基本エネルギー
1039 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1041 ENERGY energy = 10000;
1043 /* Analyze the launcher */
1046 /* Sling and ammo */
1053 /* Short Bow and Arrow */
1060 /* Long Bow and Arrow */
1067 /* Bow of irresponsiblity and Arrow */
1074 /* Light Crossbow and Bolt */
1081 /* Heavy Crossbow and Bolt */
1096 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1100 /* Analyze the launcher */
1103 /* Sling and ammo */
1110 /* Short Bow and Arrow */
1117 /* Long Bow and Arrow */
1124 /* Bow of irresponsiblity and Arrow */
1131 /* Light Crossbow and Bolt */
1138 /* Heavy Crossbow and Bolt */
1151 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1152 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1153 * @param plus_ammo 矢弾のダメージ修正
1154 * @param plus_bow 弓のダメージ修正
1156 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1158 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1161 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1163 /* Extract "shot" power */
1164 i = shooter_ptr->to_h_b + plus_ammo;
1166 if (shooter_ptr->tval_ammo == TV_BOLT)
1167 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1169 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1171 /* Snipers can shot more critically with crossbows */
1172 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1173 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1175 /* Good bow makes more critical */
1176 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1184 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1185 * @param weight 武器の重量
1186 * @param plus_ammo 矢弾のダメージ修正
1187 * @param plus_bow 弓のダメージ修正
1188 * @param dam 基本ダメージ量
1191 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1195 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1200 crit = MIN(500, 900 / weight);
1201 num += dam * 3 / 2 * crit;
1204 crit = MIN(500, 1350 / weight);
1206 num += dam * 2 * crit;
1212 num += dam * 3 * crit;
1218 num += (10000 - i) * dam;
1225 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1226 * @param shooter_ptr プレーヤーへの参照ポインタ
1227 * @param weight 武器の重量
1228 * @param plus 武器のダメージ修正
1230 * @param meichuu 命中値
1231 * @param dokubari 毒針処理か否か
1234 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1237 if (dokubari) return dam;
1239 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1245 if (k < 400) num += (2 * dam + 5) * (400 - k);
1246 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1247 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1248 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1249 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1252 if (shooter_ptr->pclass == CLASS_NINJA)
1255 num += (4444 - i) * dam;
1261 num += (5000 - i) * dam;