1 #include "combat/shoot.h"
2 #include "artifact/fixed-art-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/effect-processor.h"
8 #include "effect/spells-effect-util.h"
9 #include "flavor/flavor-describer.h"
10 #include "flavor/object-flavor-types.h"
11 #include "floor/cave.h"
12 #include "floor/floor-object.h"
13 #include "game-option/cheat-types.h"
14 #include "game-option/special-options.h"
15 #include "grid/feature-flag-types.h"
16 #include "grid/feature.h"
17 #include "grid/grid.h"
18 #include "inventory/inventory-object.h"
19 #include "inventory/inventory-slot-types.h"
20 #include "io/cursor.h"
21 #include "io/screen-util.h"
22 #include "main/sound-definitions-table.h"
23 #include "main/sound-of-music.h"
24 #include "mind/mind-sniper.h"
25 #include "mind/snipe-types.h"
26 #include "monster-floor/monster-death.h"
27 #include "monster-floor/monster-move.h"
28 #include "monster-race/monster-race.h"
29 #include "monster-race/race-flags-resistance.h"
30 #include "monster-race/race-flags1.h"
31 #include "monster-race/race-flags2.h"
32 #include "monster-race/race-flags3.h"
33 #include "monster-race/race-flags7.h"
34 #include "monster-race/race-indice-types.h"
35 #include "monster/monster-describer.h"
36 #include "monster/monster-info.h"
37 #include "monster/monster-status-setter.h"
38 #include "monster/monster-status.h"
39 #include "monster/monster-update.h"
40 #include "object-enchant/tr-types.h"
41 #include "object-hook/hook-enchant.h"
42 #include "object/object-broken.h"
43 #include "object/object-flags.h"
44 #include "object/object-generator.h"
45 #include "object/object-info.h"
46 #include "object/object-kind.h"
47 #include "object/object-mark-types.h"
48 #include "player-info/avatar.h"
49 #include "player/player-class.h"
50 #include "player/player-personalities-types.h"
51 #include "player/player-skill.h"
52 #include "player/player-status-table.h"
53 #include "player/player-status.h"
54 #include "spell/spell-types.h"
55 #include "sv-definition/sv-bow-types.h"
56 #include "system/artifact-type-definition.h"
57 #include "system/floor-type-definition.h"
58 #include "target/projection-path-calculator.h"
59 #include "target/target-checker.h"
60 #include "target/target-getter.h"
61 #include "util/bit-flags-calculator.h"
62 #include "view/display-messages.h"
63 #include "wizard/wizard-messages.h"
64 #include "world/world-object.h"
67 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
68 * Determines the odds of an object breaking when thrown at a monster
69 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
70 * @param tdam 計算途中のダメージ量
71 * @param m_ptr 目標モンスターの構造体参照ポインタ
72 * @return スレイ倍率をかけたダメージ量
74 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)
78 monster_race *r_ptr = &r_info[m_ptr->r_idx];
80 BIT_FLAGS flgs[TR_FLAG_SIZE];
81 object_flags(sniper_ptr, o_ptr, flgs);
83 /* Some "weapons" and "ammo" do extra damage */
84 switch (o_ptr->tval) {
88 if ((has_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL)) {
89 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
90 r_ptr->r_flags3 |= RF3_ANIMAL;
96 if ((has_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL)) {
97 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
98 r_ptr->r_flags3 |= RF3_ANIMAL;
104 if ((has_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL)) {
105 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
106 r_ptr->r_flags3 |= RF3_EVIL;
112 if ((has_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL)) {
113 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
114 r_ptr->r_flags3 |= RF3_EVIL;
120 if ((has_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN)) {
121 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
122 r_ptr->r_flags2 |= RF2_HUMAN;
128 if ((has_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN)) {
129 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
130 r_ptr->r_flags2 |= RF2_HUMAN;
136 if ((has_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD)) {
137 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
138 r_ptr->r_flags3 |= RF3_UNDEAD;
144 if ((has_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD)) {
145 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
146 r_ptr->r_flags3 |= RF3_UNDEAD;
152 if ((has_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON)) {
153 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
154 r_ptr->r_flags3 |= RF3_DEMON;
160 if ((has_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON)) {
161 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
162 r_ptr->r_flags3 |= RF3_DEMON;
168 if ((has_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC)) {
169 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
170 r_ptr->r_flags3 |= RF3_ORC;
176 if ((has_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC)) {
177 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
178 r_ptr->r_flags3 |= RF3_ORC;
184 if ((has_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL)) {
185 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
186 r_ptr->r_flags3 |= RF3_TROLL;
193 if ((has_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL)) {
194 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
195 r_ptr->r_flags3 |= RF3_TROLL;
201 if ((has_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT)) {
202 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
203 r_ptr->r_flags3 |= RF3_GIANT;
209 if ((has_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT)) {
210 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
211 r_ptr->r_flags3 |= RF3_GIANT;
217 if ((has_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON)) {
218 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
219 r_ptr->r_flags3 |= RF3_DRAGON;
225 if ((has_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON)) {
226 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
227 r_ptr->r_flags3 |= RF3_DRAGON;
231 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) && (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
235 if (has_flag(flgs, TR_BRAND_ACID)) {
236 /* Notice immunity */
237 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK) {
238 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
239 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
247 if (has_flag(flgs, TR_BRAND_ELEC)) {
248 /* Notice immunity */
249 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK) {
250 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
251 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
259 if (has_flag(flgs, TR_BRAND_FIRE)) {
260 /* Notice immunity */
261 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK) {
262 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
263 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
266 /* Otherwise, take the damage */
268 if (r_ptr->flags3 & RF3_HURT_FIRE) {
271 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
272 r_ptr->r_flags3 |= RF3_HURT_FIRE;
274 } else if (mult < 17)
279 if (has_flag(flgs, TR_BRAND_COLD)) {
280 /* Notice immunity */
281 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK) {
282 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
283 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
286 /* Otherwise, take the damage */
288 if (r_ptr->flags3 & RF3_HURT_COLD) {
291 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
292 r_ptr->r_flags3 |= RF3_HURT_COLD;
294 } else if (mult < 17)
299 if (has_flag(flgs, TR_BRAND_POIS)) {
300 /* Notice immunity */
301 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK) {
302 if (is_original_ap_and_seen(sniper_ptr, m_ptr)) {
303 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
306 /* Otherwise, take the damage */
313 if ((has_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30))) {
314 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
315 sniper_ptr->redraw |= (PR_MANA);
324 mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
326 /* Return the total damage */
327 return (tdam * mult / 10);
332 * Fire an object from the pack or floor.
333 * @param item 射撃するオブジェクトの所持ID
334 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
338 * You may only fire items that "match" your missile launcher.
339 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
340 * See "calc_bonuses()" for more calculations and such.
341 * Note that "firing" a missile is MUCH better than "throwing" it.
342 * Note: "unseen" monsters are very hard to hit.
343 * Objects are more likely to break if they "attempt" to hit a monster.
344 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
345 * The "extra shot" code works by decreasing the amount of energy
346 * required to make each shot, spreading the shots out over time.
347 * Note that when firing missiles, the launcher multiplier is applied
348 * after all the bonuses are added in, making multipliers very useful.
349 * Note that Bows of "Extra Might" get extra range and an extra bonus
350 * for the damage multiplier.
351 * Note that Bows of "Extra Shots" give an extra shot.
354 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
358 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
359 int tdam_base, tdis, thits, tmul;
361 int cur_dis, visible;
369 bool hit_body = FALSE;
371 GAME_TEXT o_name[MAX_NLEN];
373 u16b path_g[512]; /* For calcuration of path length */
375 int msec = delay_factor * delay_factor * delay_factor;
378 bool stick_to = FALSE;
380 /* Access the item (if in the pack) */
382 o_ptr = &shooter_ptr->inventory_list[item];
384 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
387 /* Sniper - Cannot shot a single arrow twice */
388 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2))
389 snipe_type = SP_NONE;
391 describe_flavor(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
393 /* Use the proper number of shots */
394 thits = shooter_ptr->num_fire;
396 /* Use a base distance */
399 /* Base damage from thrown object plus launcher bonus */
400 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
402 /* Actually "fire" the object */
403 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
404 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
405 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
407 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
409 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
410 tmul = bow_tmul(j_ptr->sval);
412 /* Get extra "power" from "extra might" */
413 if (shooter_ptr->xtra_might)
416 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
418 /* Boost the damage */
423 tdis = 13 + tmul / 80;
424 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW)) {
425 if (shooter_ptr->concent)
426 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
431 project_length = tdis + 1;
433 /* Get a direction (or cancel) */
434 if (!get_aim_dir(shooter_ptr, &dir)) {
435 free_turn(shooter_ptr);
437 if (snipe_type == SP_AWAY)
438 snipe_type = SP_NONE;
440 /* need not to reset project_length (already did)*/
445 /* Predict the "target" location */
446 tx = shooter_ptr->x + 99 * ddx[dir];
447 ty = shooter_ptr->y + 99 * ddy[dir];
449 /* Check for "target request" */
450 if ((dir == 5) && target_okay(shooter_ptr)) {
455 /* Get projection path length */
456 tdis = projection_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
458 project_length = 0; /* reset to default */
460 /* Don't shoot at my feet */
461 if (tx == shooter_ptr->x && ty == shooter_ptr->y) {
462 free_turn(shooter_ptr);
464 /* project_length is already reset to 0 */
469 /* Take a (partial) turn */
470 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
471 shooter_ptr->is_fired = TRUE;
473 /* Sniper - Difficult to shot twice at 1 turn */
474 if (snipe_type == SP_DOUBLE)
475 shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
477 /* Sniper - Repeat shooting when double shots */
478 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++) {
479 /* Start at the player */
483 object_copy(q_ptr, o_ptr);
488 vary_item(shooter_ptr, item, -1);
491 handle_stuff(shooter_ptr);
496 /* The shot does not hit yet */
499 /* Travel until stopped */
500 for (cur_dis = 0; cur_dis <= tdis;) {
503 /* Hack -- Stop at the target */
504 if ((y == ty) && (x == tx))
507 /* Calculate the new location (see "project()") */
510 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
513 if (snipe_type == SP_KILL_WALL) {
514 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
516 if (cave_has_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx) {
517 if (g_ptr->info & (CAVE_MARK))
518 msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
519 /* Forget the wall */
520 g_ptr->info &= ~(CAVE_MARK);
521 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
523 /* Destroy the wall */
524 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
531 /* Stopped by walls/doors */
532 if (!cave_has_flag_bold(shooter_ptr->current_floor_ptr, ny, nx, FF_PROJECT) && !shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx)
535 /* Advance the distance */
539 if (snipe_type == SP_LITE) {
540 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
541 note_spot(shooter_ptr, ny, nx);
542 lite_spot(shooter_ptr, ny, nx);
545 /* The player can see the (on screen) missile */
546 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx)) {
547 SYMBOL_CODE c = object_char(q_ptr);
548 byte a = object_attr(q_ptr);
550 /* Draw, Hilite, Fresh, Pause, Erase */
551 print_rel(shooter_ptr, c, a, ny, nx);
552 move_cursor_relative(ny, nx);
554 term_xtra(TERM_XTRA_DELAY, msec);
555 lite_spot(shooter_ptr, ny, nx);
559 /* The player cannot see the missile */
561 /* Pause anyway, for consistancy */
562 term_xtra(TERM_XTRA_DELAY, msec);
566 if (snipe_type == SP_KILL_TRAP) {
567 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP, (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
571 if (snipe_type == SP_EVILNESS) {
572 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
573 note_spot(shooter_ptr, ny, nx);
574 lite_spot(shooter_ptr, ny, nx);
580 /* Save the new location */
584 /* Monster here, Try to hit it */
585 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
586 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
588 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
589 monster_race *r_ptr = &r_info[m_ptr->r_idx];
591 /* Check the visibility */
594 /* Note the collision */
597 if (monster_csleep_remaining(m_ptr)) {
598 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5))
599 chg_virtue(shooter_ptr, V_COMPASSION, -1);
600 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5))
601 chg_virtue(shooter_ptr, V_HONOUR, -1);
604 if ((r_ptr->level + 10) > shooter_ptr->lev) {
605 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
606 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval]) {
608 if (now_exp < WEAPON_EXP_BEGINNER)
610 else if (now_exp < WEAPON_EXP_SKILLED)
612 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19))
614 else if (shooter_ptr->lev > 34)
616 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
617 shooter_ptr->update |= (PU_BONUS);
621 if (shooter_ptr->riding) {
622 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
623 && ((shooter_ptr->skill_exp[GINOU_RIDING] - (RIDING_EXP_BEGINNER * 2)) / 200
624 < r_info[shooter_ptr->current_floor_ptr->m_list[shooter_ptr->riding].r_idx].level)
626 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
627 shooter_ptr->update |= (PU_BONUS);
631 /* Did we hit it (penalize range) */
632 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name)) {
634 int tdam = tdam_base;
636 /* Get extra damage from concentration */
637 if (shooter_ptr->concent)
638 tdam = boost_concentration_damage(shooter_ptr, tdam);
640 /* Handle unseen monster */
642 /* Invisible monster */
643 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
646 /* Handle visible monster */
648 GAME_TEXT m_name[MAX_NLEN];
650 /* Get "the monster" or "it" */
651 monster_desc(shooter_ptr, m_name, m_ptr, 0);
653 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
656 if (!shooter_ptr->image)
657 monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
658 health_track(shooter_ptr, c_mon_ptr->m_idx);
662 if (snipe_type == SP_NEEDLE) {
663 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1) && !(r_ptr->flags1 & RF1_UNIQUE)
664 && !(r_ptr->flags7 & RF7_UNIQUE2)) {
665 GAME_TEXT m_name[MAX_NLEN];
667 /* Get "the monster" or "it" */
668 monster_desc(shooter_ptr, m_name, m_ptr, 0);
670 tdam = m_ptr->hp + 1;
671 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
675 /* Apply special damage */
676 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
677 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
679 /* No negative damage */
683 /* Modify the damage */
684 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
687 msg_format_wizard(shooter_ptr, CHEAT_MONSTER, _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"), tdam,
688 m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
691 if (snipe_type == SP_EXPLODE) {
692 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
694 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
695 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
700 if (snipe_type == SP_HOLYNESS) {
701 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
702 note_spot(shooter_ptr, ny, nx);
703 lite_spot(shooter_ptr, ny, nx);
706 /* Hit the monster, check for death */
707 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr)))) {
714 if (object_is_fixed_artifact(q_ptr) && (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0)) {
715 GAME_TEXT m_name[MAX_NLEN];
717 monster_desc(shooter_ptr, m_name, m_ptr, 0);
720 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
723 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
725 /* Anger the monster */
727 anger_monster(shooter_ptr, m_ptr);
729 if (fear && m_ptr->ml) {
730 GAME_TEXT m_name[MAX_NLEN];
732 monster_desc(shooter_ptr, m_name, m_ptr, 0);
733 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
736 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
739 if (snipe_type == SP_RUSH) {
740 int n = randint1(5) + 3;
741 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
743 for (; cur_dis <= tdis;) {
750 /* Calculate the new location (see "project()") */
751 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
753 /* Stopped by wilderness boundary */
754 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx))
757 /* Stopped by walls/doors */
758 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0))
761 /* Stopped by monsters */
762 if (!is_cave_empty_bold(shooter_ptr, ny, nx))
765 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
766 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
771 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
773 lite_spot(shooter_ptr, ny, nx);
774 lite_spot(shooter_ptr, oy, ox);
776 term_xtra(TERM_XTRA_DELAY, msec);
788 if (snipe_type == SP_PIERCE) {
789 if (shooter_ptr->concent < 1)
791 shooter_ptr->concent--;
800 /* Chance of breakage (during attacks) */
801 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
804 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
805 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
806 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
809 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
810 if (object_is_fixed_artifact(q_ptr)) {
811 a_info[j_ptr->name1].cur_num = 0;
816 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
817 object_copy(o_ptr, q_ptr);
820 o_ptr->marked &= OM_TOUCHED;
822 /* Forget location */
823 o_ptr->iy = o_ptr->ix = 0;
825 /* Memorize monster */
826 o_ptr->held_m_idx = m_idx;
829 o_ptr->next_o_idx = m_ptr->hold_o_idx;
832 m_ptr->hold_o_idx = o_idx;
833 } else if (cave_has_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT)) {
834 /* Drop (or break) near that location */
835 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
837 /* Drop (or break) near that location */
838 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
841 /* Sniper - Repeat shooting when double shots */
844 /* Sniper - Loose his/her concentration after any shot */
845 if (shooter_ptr->concent)
846 reset_concentration(shooter_ptr, FALSE);
850 * @brief プレイヤーからモンスターへの射撃命中判定 /
851 * Determine if the player "hits" a monster (normal combat).
852 * @param chance 基本命中値
853 * @param m_ptr モンスターの構造体参照ポインタ
854 * @param vis 目標を視界に捕らえているならばTRUEを指定
855 * @param o_name メッセージ表示時のモンスター名
856 * @return 命中と判定された場合TRUEを返す
857 * @note Always miss 5%, always hit 5%, otherwise random.
859 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char *o_name)
863 monster_race *r_ptr = &r_info[m_ptr->r_idx];
865 /* Percentile dice */
868 /* Snipers with high-concentration reduce instant miss percentage.*/
869 k += shooter_ptr->concent;
871 /* Hack -- Instant miss or hit */
877 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
886 if (shooter_ptr->concent) {
887 ac *= (8 - shooter_ptr->concent);
891 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
894 /* Invisible monsters are harder to hit */
896 chance = (chance + 1) / 2;
898 /* Power competes against armor */
899 if (randint0(chance) < (ac * 3 / 4)) {
900 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) {
901 GAME_TEXT m_name[MAX_NLEN];
902 monster_desc(shooter_ptr, m_name, m_ptr, 0);
903 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
913 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
914 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
915 * @param weight 矢弾の重量
916 * @param plus_ammo 矢弾の命中修正
917 * @param plus_bow 弓の命中修正
918 * @param dam 現在算出中のダメージ値
919 * @return クリティカル修正が入ったダメージ値
921 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
924 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
926 /* Extract "shot" power */
927 i = shooter_ptr->to_h_b + plus_ammo;
929 if (shooter_ptr->tval_ammo == TV_BOLT)
930 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
932 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
934 /* Snipers can shot more critically with crossbows */
935 if (shooter_ptr->concent)
936 i += ((i * shooter_ptr->concent) / 5);
937 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT))
940 /* Good bow makes more critical */
941 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
944 if (randint1(10000) <= i) {
945 k = weight * randint1(500);
948 msg_print(_("手ごたえがあった!", "It was a good hit!"));
950 } else if (k < 1350) {
951 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
954 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
963 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
964 * @param sval 射撃武器のアイテム副分類ID
965 * @return 消費する基本エネルギー
967 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
969 ENERGY energy = 10000;
971 /* Analyze the launcher */
979 /* Short Bow and Arrow */
985 /* Long Bow and Arrow */
991 /* Bow of irresponsiblity and Arrow */
992 case SV_NAMAKE_BOW: {
997 /* Light Crossbow and Bolt */
998 case SV_LIGHT_XBOW: {
1003 /* Heavy Crossbow and Bolt */
1004 case SV_HEAVY_XBOW: {
1016 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1020 /* Analyze the launcher */
1022 /* Sling and ammo */
1028 /* Short Bow and Arrow */
1029 case SV_SHORT_BOW: {
1034 /* Long Bow and Arrow */
1040 /* Bow of irresponsiblity and Arrow */
1041 case SV_NAMAKE_BOW: {
1046 /* Light Crossbow and Bolt */
1047 case SV_LIGHT_XBOW: {
1052 /* Heavy Crossbow and Bolt */
1053 case SV_HEAVY_XBOW: {
1063 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1064 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1065 * @param plus_ammo 矢弾のダメージ修正
1066 * @param plus_bow 弓のダメージ修正
1068 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1070 HIT_POINT calc_crit_ratio_shot(player_type *shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1073 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1075 /* Extract "shot" power */
1076 i = shooter_ptr->to_h_b + plus_ammo;
1078 if (shooter_ptr->tval_ammo == TV_BOLT)
1079 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1081 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1083 /* Snipers can shot more critically with crossbows */
1084 if (shooter_ptr->concent)
1085 i += ((i * shooter_ptr->concent) / 5);
1086 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT))
1089 /* Good bow makes more critical */
1090 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1099 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1100 * @param weight 武器の重量
1101 * @param plus_ammo 矢弾のダメージ修正
1102 * @param plus_bow 弓のダメージ修正
1103 * @param dam 基本ダメージ量
1106 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1110 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1115 crit = MIN(500, 900 / weight);
1116 num += dam * 3 / 2 * crit;
1119 crit = MIN(500, 1350 / weight);
1121 num += dam * 2 * crit;
1126 num += dam * 3 * crit;
1132 num += (10000 - i) * dam;
1139 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1140 * @param shooter_ptr プレーヤーへの参照ポインタ
1141 * @param weight 武器の重量
1142 * @param plus 武器のダメージ修正
1144 * @param meichuu 命中値
1145 * @param dokubari 毒針処理か否か
1148 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1154 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1162 num += (2 * dam + 5) * (400 - k);
1164 num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1165 if (k > (700 - 650) && k < 900)
1166 num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1167 if (k > (900 - 650) && k < 1300)
1168 num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1169 if (k > (1300 - 650))
1170 num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1173 if (shooter_ptr->pclass == CLASS_NINJA) {
1175 num += (4444 - i) * dam;
1179 num += (5000 - i) * dam;