1 #include "system/angband.h"
2 #include "core/stuff-handler.h"
4 #include "main/sound-definitions-table.h"
5 #include "term/gameterm.h"
7 #include "monster/monster.h"
8 #include "monster/monster-status.h"
9 #include "mspell/monster-spell.h"
10 #include "object/artifact.h"
11 #include "player/avatar.h"
12 #include "player/player-status.h"
13 #include "player/player-skill.h"
14 #include "player/player-class.h"
15 #include "player/player-personalities-table.h"
16 #include "object/object-hook.h"
17 #include "object/object-broken.h"
18 #include "effect/effect-characteristics.h"
19 #include "grid/grid.h"
20 #include "object/object-flavor.h"
23 #include "combat/snipe.h"
24 #include "view/display-main-window.h"
25 #include "object/object-kind.h"
26 #include "io/targeting.h"
27 #include "effect/spells-effect-util.h"
28 #include "spell/process-effect.h"
29 #include "object/tr-types.h"
32 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
33 * Determines the odds of an object breaking when thrown at a monster
34 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
35 * @param tdam 計算途中のダメージ量
36 * @param m_ptr 目標モンスターの構造体参照ポインタ
37 * @return スレイ倍率をかけたダメージ量
39 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)
43 monster_race *r_ptr = &r_info[m_ptr->r_idx];
45 BIT_FLAGS flgs[TR_FLAG_SIZE];
46 object_flags(o_ptr, flgs);
48 /* Some "weapons" and "ammo" do extra damage */
55 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
57 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
59 r_ptr->r_flags3 |= RF3_ANIMAL;
61 if (mult < 17) mult = 17;
64 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
66 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
68 r_ptr->r_flags3 |= RF3_ANIMAL;
70 if (mult < 27) mult = 27;
73 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
75 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
77 r_ptr->r_flags3 |= RF3_EVIL;
79 if (mult < 15) mult = 15;
82 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
84 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
86 r_ptr->r_flags3 |= RF3_EVIL;
88 if (mult < 25) mult = 25;
91 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
93 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
95 r_ptr->r_flags2 |= RF2_HUMAN;
97 if (mult < 17) mult = 17;
100 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
102 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
104 r_ptr->r_flags2 |= RF2_HUMAN;
106 if (mult < 27) mult = 27;
109 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
111 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
113 r_ptr->r_flags3 |= RF3_UNDEAD;
115 if (mult < 20) mult = 20;
118 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
120 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
122 r_ptr->r_flags3 |= RF3_UNDEAD;
124 if (mult < 30) mult = 30;
127 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
129 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
131 r_ptr->r_flags3 |= RF3_DEMON;
133 if (mult < 20) mult = 20;
136 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
138 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
140 r_ptr->r_flags3 |= RF3_DEMON;
142 if (mult < 30) mult = 30;
145 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
147 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
149 r_ptr->r_flags3 |= RF3_ORC;
151 if (mult < 20) mult = 20;
154 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
156 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
158 r_ptr->r_flags3 |= RF3_ORC;
160 if (mult < 30) mult = 30;
163 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
165 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
167 r_ptr->r_flags3 |= RF3_TROLL;
170 if (mult < 20) mult = 20;
173 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
175 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
177 r_ptr->r_flags3 |= RF3_TROLL;
179 if (mult < 30) mult = 30;
182 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
184 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
186 r_ptr->r_flags3 |= RF3_GIANT;
188 if (mult < 20) mult = 20;
191 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
193 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
195 r_ptr->r_flags3 |= RF3_GIANT;
197 if (mult < 30) mult = 30;
200 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
202 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
204 r_ptr->r_flags3 |= RF3_DRAGON;
206 if (mult < 20) mult = 20;
209 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
211 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
213 r_ptr->r_flags3 |= RF3_DRAGON;
215 if (mult < 30) mult = 30;
216 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
217 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
221 if (have_flag(flgs, TR_BRAND_ACID))
223 /* Notice immunity */
224 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
226 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
228 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
233 if (mult < 17) mult = 17;
237 if (have_flag(flgs, TR_BRAND_ELEC))
239 /* Notice immunity */
240 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
242 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
244 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
249 if (mult < 17) mult = 17;
253 if (have_flag(flgs, TR_BRAND_FIRE))
255 /* Notice immunity */
256 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
258 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
260 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
263 /* Otherwise, take the damage */
266 if (r_ptr->flags3 & RF3_HURT_FIRE)
268 if (mult < 25) mult = 25;
269 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
271 r_ptr->r_flags3 |= RF3_HURT_FIRE;
274 else if (mult < 17) mult = 17;
278 if (have_flag(flgs, TR_BRAND_COLD))
280 /* Notice immunity */
281 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
283 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
285 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
288 /* Otherwise, take the damage */
291 if (r_ptr->flags3 & RF3_HURT_COLD)
293 if (mult < 25) mult = 25;
294 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
296 r_ptr->r_flags3 |= RF3_HURT_COLD;
299 else if (mult < 17) mult = 17;
303 if (have_flag(flgs, TR_BRAND_POIS))
305 /* Notice immunity */
306 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
308 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
310 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
313 /* Otherwise, take the damage */
316 if (mult < 17) mult = 17;
320 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
322 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
323 sniper_ptr->redraw |= (PR_MANA);
331 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
333 /* Return the total damage */
334 return (tdam * mult / 10);
340 * Fire an object from the pack or floor.
341 * @param item 射撃するオブジェクトの所持ID
342 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
346 * You may only fire items that "match" your missile launcher.
347 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
348 * See "calc_bonuses()" for more calculations and such.
349 * Note that "firing" a missile is MUCH better than "throwing" it.
350 * Note: "unseen" monsters are very hard to hit.
351 * Objects are more likely to break if they "attempt" to hit a monster.
352 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
353 * The "extra shot" code works by decreasing the amount of energy
354 * required to make each shot, spreading the shots out over time.
355 * Note that when firing missiles, the launcher multiplier is applied
356 * after all the bonuses are added in, making multipliers very useful.
357 * Note that Bows of "Extra Might" get extra range and an extra bonus
358 * for the damage multiplier.
359 * Note that Bows of "Extra Shots" give an extra shot.
362 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
366 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
367 int tdam_base, tdis, thits, tmul;
369 int cur_dis, visible;
377 bool hit_body = FALSE;
379 GAME_TEXT o_name[MAX_NLEN];
381 u16b path_g[512]; /* For calcuration of path length */
383 int msec = delay_factor * delay_factor * delay_factor;
386 bool stick_to = FALSE;
388 /* Access the item (if in the pack) */
391 o_ptr = &shooter_ptr->inventory_list[item];
395 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
398 /* Sniper - Cannot shot a single arrow twice */
399 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
401 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
403 /* Use the proper number of shots */
404 thits = shooter_ptr->num_fire;
406 /* Use a base distance */
409 /* Base damage from thrown object plus launcher bonus */
410 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
412 /* Actually "fire" the object */
413 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
414 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
415 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
417 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
419 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
420 tmul = bow_tmul(j_ptr->sval);
422 /* Get extra "power" from "extra might" */
423 if (shooter_ptr->xtra_might) tmul++;
425 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
427 /* Boost the damage */
432 tdis = 13 + tmul / 80;
433 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
435 if (shooter_ptr->concent)
436 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
441 project_length = tdis + 1;
443 /* Get a direction (or cancel) */
444 if (!get_aim_dir(shooter_ptr, &dir))
446 free_turn(shooter_ptr);
448 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
450 /* need not to reset project_length (already did)*/
455 /* Predict the "target" location */
456 tx = shooter_ptr->x + 99 * ddx[dir];
457 ty = shooter_ptr->y + 99 * ddy[dir];
459 /* Check for "target request" */
460 if ((dir == 5) && target_okay(shooter_ptr))
466 /* Get projection path length */
467 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
469 project_length = 0; /* reset to default */
471 /* Don't shoot at my feet */
472 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
474 free_turn(shooter_ptr);
476 /* project_length is already reset to 0 */
482 /* Take a (partial) turn */
483 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
484 shooter_ptr->is_fired = TRUE;
486 /* Sniper - Difficult to shot twice at 1 turn */
487 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
489 /* Sniper - Repeat shooting when double shots */
490 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
493 /* Start at the player */
497 object_copy(q_ptr, o_ptr);
502 vary_item(shooter_ptr, item, -1);
505 handle_stuff(shooter_ptr);
510 /* The shot does not hit yet */
513 /* Travel until stopped */
514 for (cur_dis = 0; cur_dis <= tdis; )
518 /* Hack -- Stop at the target */
519 if ((y == ty) && (x == tx)) break;
521 /* Calculate the new location (see "project()") */
524 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
527 if (snipe_type == SP_KILL_WALL)
529 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
531 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
533 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
534 /* Forget the wall */
535 g_ptr->info &= ~(CAVE_MARK);
536 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
538 /* Destroy the wall */
539 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
546 /* Stopped by walls/doors */
547 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;
549 /* Advance the distance */
553 if (snipe_type == SP_LITE)
555 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
556 note_spot(shooter_ptr, ny, nx);
557 lite_spot(shooter_ptr, ny, nx);
560 /* The player can see the (on screen) missile */
561 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
563 char c = object_char(q_ptr);
564 byte a = object_attr(q_ptr);
566 /* Draw, Hilite, Fresh, Pause, Erase */
567 print_rel(shooter_ptr, c, a, ny, nx);
568 move_cursor_relative(ny, nx);
570 Term_xtra(TERM_XTRA_DELAY, msec);
571 lite_spot(shooter_ptr, ny, nx);
575 /* The player cannot see the missile */
578 /* Pause anyway, for consistancy */
579 Term_xtra(TERM_XTRA_DELAY, msec);
583 if (snipe_type == SP_KILL_TRAP)
585 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
586 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
590 if (snipe_type == SP_EVILNESS)
592 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
593 note_spot(shooter_ptr, ny, nx);
594 lite_spot(shooter_ptr, ny, nx);
600 /* Save the new location */
604 /* Monster here, Try to hit it */
605 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
607 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
609 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
610 monster_race *r_ptr = &r_info[m_ptr->r_idx];
612 /* Check the visibility */
615 /* Note the collision */
618 if (MON_CSLEEP(m_ptr))
620 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
621 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
624 if ((r_ptr->level + 10) > shooter_ptr->lev)
626 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
627 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
630 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
631 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
632 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
633 else if (shooter_ptr->lev > 34) amount = 2;
634 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
635 shooter_ptr->update |= (PU_BONUS);
639 if (shooter_ptr->riding)
641 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
642 && ((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)
645 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
646 shooter_ptr->update |= (PU_BONUS);
650 /* Did we hit it (penalize range) */
651 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
654 int tdam = tdam_base;
656 /* Get extra damage from concentration */
657 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
659 /* Handle unseen monster */
662 /* Invisible monster */
663 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
666 /* Handle visible monster */
669 GAME_TEXT m_name[MAX_NLEN];
671 /* Get "the monster" or "it" */
672 monster_desc(shooter_ptr, m_name, m_ptr, 0);
674 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
678 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
679 health_track(shooter_ptr, c_mon_ptr->m_idx);
683 if (snipe_type == SP_NEEDLE)
685 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
686 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
688 GAME_TEXT m_name[MAX_NLEN];
690 /* Get "the monster" or "it" */
691 monster_desc(shooter_ptr, m_name, m_ptr, 0);
693 tdam = m_ptr->hp + 1;
694 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
700 /* Apply special damage */
701 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
702 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
704 /* No negative damage */
705 if (tdam < 0) tdam = 0;
707 /* Modify the damage */
708 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
711 msg_format_wizard(CHEAT_MONSTER,
712 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
713 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
716 if (snipe_type == SP_EXPLODE)
718 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
720 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
721 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
726 if (snipe_type == SP_HOLYNESS)
728 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
729 note_spot(shooter_ptr, ny, nx);
730 lite_spot(shooter_ptr, ny, nx);
733 /* Hit the monster, check for death */
734 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
743 if (object_is_fixed_artifact(q_ptr) &&
744 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
746 GAME_TEXT m_name[MAX_NLEN];
748 monster_desc(shooter_ptr, m_name, m_ptr, 0);
751 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
754 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
756 /* Anger the monster */
757 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
759 if (fear && m_ptr->ml)
761 GAME_TEXT m_name[MAX_NLEN];
763 monster_desc(shooter_ptr, m_name, m_ptr, 0);
764 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
767 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
770 if (snipe_type == SP_RUSH)
772 int n = randint1(5) + 3;
773 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
775 for (; cur_dis <= tdis; )
782 /* Calculate the new location (see "project()") */
783 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
785 /* Stopped by wilderness boundary */
786 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
788 /* Stopped by walls/doors */
789 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
791 /* Stopped by monsters */
792 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
794 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
795 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
800 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
802 lite_spot(shooter_ptr, ny, nx);
803 lite_spot(shooter_ptr, oy, ox);
806 Term_xtra(TERM_XTRA_DELAY, msec);
818 if (snipe_type == SP_PIERCE)
820 if (shooter_ptr->concent < 1) break;
821 shooter_ptr->concent--;
830 /* Chance of breakage (during attacks) */
831 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
835 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
836 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
837 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
841 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
842 if (object_is_fixed_artifact(q_ptr))
844 a_info[j_ptr->name1].cur_num = 0;
849 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
850 object_copy(o_ptr, q_ptr);
853 o_ptr->marked &= OM_TOUCHED;
855 /* Forget location */
856 o_ptr->iy = o_ptr->ix = 0;
858 /* Memorize monster */
859 o_ptr->held_m_idx = m_idx;
862 o_ptr->next_o_idx = m_ptr->hold_o_idx;
865 m_ptr->hold_o_idx = o_idx;
867 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
869 /* Drop (or break) near that location */
870 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
874 /* Drop (or break) near that location */
875 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
878 /* Sniper - Repeat shooting when double shots */
881 /* Sniper - Loose his/her concentration after any shot */
882 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
887 * @brief プレイヤーからモンスターへの射撃命中判定 /
888 * Determine if the player "hits" a monster (normal combat).
889 * @param chance 基本命中値
890 * @param m_ptr モンスターの構造体参照ポインタ
891 * @param vis 目標を視界に捕らえているならばTRUEを指定
892 * @param o_name メッセージ表示時のモンスター名
893 * @return 命中と判定された場合TRUEを返す
894 * @note Always miss 5%, always hit 5%, otherwise random.
896 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
900 monster_race *r_ptr = &r_info[m_ptr->r_idx];
902 /* Percentile dice */
905 /* Snipers with high-concentration reduce instant miss percentage.*/
906 k += shooter_ptr->concent;
908 /* Hack -- Instant miss or hit */
909 if (k <= 5) return FALSE;
910 if (k > 95) return TRUE;
912 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
913 if (one_in_(20)) return FALSE;
916 if (chance <= 0) return FALSE;
919 if (shooter_ptr->concent)
921 ac *= (8 - shooter_ptr->concent);
925 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
927 /* Invisible monsters are harder to hit */
928 if (!vis) chance = (chance + 1) / 2;
930 /* Power competes against armor */
931 if (randint0(chance) < (ac * 3 / 4))
933 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
935 GAME_TEXT m_name[MAX_NLEN];
936 monster_desc(shooter_ptr, m_name, m_ptr, 0);
937 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
950 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
951 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
952 * @param weight 矢弾の重量
953 * @param plus_ammo 矢弾の命中修正
954 * @param plus_bow 弓の命中修正
955 * @param dam 現在算出中のダメージ値
956 * @return クリティカル修正が入ったダメージ値
958 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
961 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
963 /* Extract "shot" power */
964 i = shooter_ptr->to_h_b + plus_ammo;
966 if (shooter_ptr->tval_ammo == TV_BOLT)
967 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
969 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
972 /* Snipers can shot more critically with crossbows */
973 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
974 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
976 /* Good bow makes more critical */
977 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
980 if (randint1(10000) <= i)
982 k = weight * randint1(500);
986 msg_print(_("手ごたえがあった!", "It was a good hit!"));
991 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
996 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1008 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1009 * @param sval 射撃武器のアイテム副分類ID
1010 * @return 消費する基本エネルギー
1012 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1014 ENERGY energy = 10000;
1016 /* Analyze the launcher */
1019 /* Sling and ammo */
1026 /* Short Bow and Arrow */
1033 /* Long Bow and Arrow */
1040 /* Bow of irresponsiblity and Arrow */
1047 /* Light Crossbow and Bolt */
1054 /* Heavy Crossbow and Bolt */
1069 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1073 /* Analyze the launcher */
1076 /* Sling and ammo */
1083 /* Short Bow and Arrow */
1090 /* Long Bow and Arrow */
1097 /* Bow of irresponsiblity and Arrow */
1104 /* Light Crossbow and Bolt */
1111 /* Heavy Crossbow and Bolt */
1124 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1125 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1126 * @param plus_ammo 矢弾のダメージ修正
1127 * @param plus_bow 弓のダメージ修正
1129 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1131 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1134 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1136 /* Extract "shot" power */
1137 i = shooter_ptr->to_h_b + plus_ammo;
1139 if (shooter_ptr->tval_ammo == TV_BOLT)
1140 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1142 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1144 /* Snipers can shot more critically with crossbows */
1145 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1146 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1148 /* Good bow makes more critical */
1149 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1157 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1158 * @param weight 武器の重量
1159 * @param plus_ammo 矢弾のダメージ修正
1160 * @param plus_bow 弓のダメージ修正
1161 * @param dam 基本ダメージ量
1164 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1168 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1173 crit = MIN(500, 900 / weight);
1174 num += dam * 3 / 2 * crit;
1177 crit = MIN(500, 1350 / weight);
1179 num += dam * 2 * crit;
1185 num += dam * 3 * crit;
1191 num += (10000 - i) * dam;
1198 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1199 * @param shooter_ptr プレーヤーへの参照ポインタ
1200 * @param weight 武器の重量
1201 * @param plus 武器のダメージ修正
1203 * @param meichuu 命中値
1204 * @param dokubari 毒針処理か否か
1207 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1210 if (dokubari) return dam;
1212 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1218 if (k < 400) num += (2 * dam + 5) * (400 - k);
1219 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1220 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1221 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1222 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1225 if (shooter_ptr->pclass == CLASS_NINJA)
1228 num += (4444 - i) * dam;
1234 num += (5000 - i) * dam;