7 #include "monster-status.h"
8 #include "monster-spell.h"
11 #include "player-status.h"
12 #include "player-skill.h"
13 #include "player-class.h"
14 #include "player-personality.h"
15 #include "object-hook.h"
16 #include "object-broken.h"
20 #include "object-flavor.h"
24 #include "view-mainwindow.h"
25 #include "objectkind.h"
26 #include "targeting.h"
29 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
30 * Determines the odds of an object breaking when thrown at a monster
31 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
32 * @param tdam 計算途中のダメージ量
33 * @param m_ptr 目標モンスターの構造体参照ポインタ
34 * @return スレイ倍率をかけたダメージ量
36 static MULTIPLY tot_dam_aux_shot(player_type *sniper_ptr, object_type *o_ptr, HIT_POINT tdam, monster_type *m_ptr, SPELL_IDX snipe_type)
40 monster_race *r_ptr = &r_info[m_ptr->r_idx];
42 BIT_FLAGS flgs[TR_FLAG_SIZE];
43 object_flags(o_ptr, flgs);
45 /* Some "weapons" and "ammo" do extra damage */
52 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
54 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
56 r_ptr->r_flags3 |= RF3_ANIMAL;
58 if (mult < 17) mult = 17;
61 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
63 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
65 r_ptr->r_flags3 |= RF3_ANIMAL;
67 if (mult < 27) mult = 27;
70 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
72 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
74 r_ptr->r_flags3 |= RF3_EVIL;
76 if (mult < 15) mult = 15;
79 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
81 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
83 r_ptr->r_flags3 |= RF3_EVIL;
85 if (mult < 25) mult = 25;
88 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
90 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
92 r_ptr->r_flags2 |= RF2_HUMAN;
94 if (mult < 17) mult = 17;
97 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
99 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
101 r_ptr->r_flags2 |= RF2_HUMAN;
103 if (mult < 27) mult = 27;
106 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
108 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
110 r_ptr->r_flags3 |= RF3_UNDEAD;
112 if (mult < 20) mult = 20;
115 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
117 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
119 r_ptr->r_flags3 |= RF3_UNDEAD;
121 if (mult < 30) mult = 30;
124 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
126 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
128 r_ptr->r_flags3 |= RF3_DEMON;
130 if (mult < 20) mult = 20;
133 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
135 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
137 r_ptr->r_flags3 |= RF3_DEMON;
139 if (mult < 30) mult = 30;
142 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
144 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
146 r_ptr->r_flags3 |= RF3_ORC;
148 if (mult < 20) mult = 20;
151 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
153 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
155 r_ptr->r_flags3 |= RF3_ORC;
157 if (mult < 30) mult = 30;
160 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
162 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
164 r_ptr->r_flags3 |= RF3_TROLL;
167 if (mult < 20) mult = 20;
170 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
172 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
174 r_ptr->r_flags3 |= RF3_TROLL;
176 if (mult < 30) mult = 30;
179 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
181 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
183 r_ptr->r_flags3 |= RF3_GIANT;
185 if (mult < 20) mult = 20;
188 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
190 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
192 r_ptr->r_flags3 |= RF3_GIANT;
194 if (mult < 30) mult = 30;
197 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
199 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
201 r_ptr->r_flags3 |= RF3_DRAGON;
203 if (mult < 20) mult = 20;
206 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
208 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
210 r_ptr->r_flags3 |= RF3_DRAGON;
212 if (mult < 30) mult = 30;
213 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
214 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
218 if (have_flag(flgs, TR_BRAND_ACID))
220 /* Notice immunity */
221 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
223 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
225 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
230 if (mult < 17) mult = 17;
234 if (have_flag(flgs, TR_BRAND_ELEC))
236 /* Notice immunity */
237 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
239 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
241 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
246 if (mult < 17) mult = 17;
250 if (have_flag(flgs, TR_BRAND_FIRE))
252 /* Notice immunity */
253 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
255 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
257 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
260 /* Otherwise, take the damage */
263 if (r_ptr->flags3 & RF3_HURT_FIRE)
265 if (mult < 25) mult = 25;
266 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
268 r_ptr->r_flags3 |= RF3_HURT_FIRE;
271 else if (mult < 17) mult = 17;
275 if (have_flag(flgs, TR_BRAND_COLD))
277 /* Notice immunity */
278 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
280 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
282 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
285 /* Otherwise, take the damage */
288 if (r_ptr->flags3 & RF3_HURT_COLD)
290 if (mult < 25) mult = 25;
291 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
293 r_ptr->r_flags3 |= RF3_HURT_COLD;
296 else if (mult < 17) mult = 17;
300 if (have_flag(flgs, TR_BRAND_POIS))
302 /* Notice immunity */
303 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
305 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
307 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
310 /* Otherwise, take the damage */
313 if (mult < 17) mult = 17;
317 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
319 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
320 sniper_ptr->redraw |= (PR_MANA);
328 if (snipe_type) mult = tot_dam_aux_snipe(sniper_ptr, mult, m_ptr, snipe_type);
330 /* Return the total damage */
331 return (tdam * mult / 10);
337 * Fire an object from the pack or floor.
338 * @param item 射撃するオブジェクトの所持ID
339 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
343 * You may only fire items that "match" your missile launcher.
344 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
345 * See "calc_bonuses()" for more calculations and such.
346 * Note that "firing" a missile is MUCH better than "throwing" it.
347 * Note: "unseen" monsters are very hard to hit.
348 * Objects are more likely to break if they "attempt" to hit a monster.
349 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
350 * The "extra shot" code works by decreasing the amount of energy
351 * required to make each shot, spreading the shots out over time.
352 * Note that when firing missiles, the launcher multiplier is applied
353 * after all the bonuses are added in, making multipliers very useful.
354 * Note that Bows of "Extra Might" get extra range and an extra bonus
355 * for the damage multiplier.
356 * Note that Bows of "Extra Shots" give an extra shot.
359 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
363 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
364 int tdam_base, tdis, thits, tmul;
366 int cur_dis, visible;
374 bool hit_body = FALSE;
376 GAME_TEXT o_name[MAX_NLEN];
378 u16b path_g[512]; /* For calcuration of path length */
380 int msec = delay_factor * delay_factor * delay_factor;
383 bool stick_to = FALSE;
385 /* Access the item (if in the pack) */
388 o_ptr = &shooter_ptr->inventory_list[item];
392 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
395 /* Sniper - Cannot shot a single arrow twice */
396 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
398 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
400 /* Use the proper number of shots */
401 thits = shooter_ptr->num_fire;
403 /* Use a base distance */
406 /* Base damage from thrown object plus launcher bonus */
407 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
409 /* Actually "fire" the object */
410 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
411 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
412 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
414 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
416 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
417 tmul = bow_tmul(j_ptr->sval);
419 /* Get extra "power" from "extra might" */
420 if (shooter_ptr->xtra_might) tmul++;
422 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
424 /* Boost the damage */
429 tdis = 13 + tmul / 80;
430 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
432 if (shooter_ptr->concent)
433 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
438 project_length = tdis + 1;
440 /* Get a direction (or cancel) */
441 if (!get_aim_dir(shooter_ptr, &dir))
443 free_turn(shooter_ptr);
445 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
447 /* need not to reset project_length (already did)*/
452 /* Predict the "target" location */
453 tx = shooter_ptr->x + 99 * ddx[dir];
454 ty = shooter_ptr->y + 99 * ddy[dir];
456 /* Check for "target request" */
457 if ((dir == 5) && target_okay(shooter_ptr))
463 /* Get projection path length */
464 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
466 project_length = 0; /* reset to default */
468 /* Don't shoot at my feet */
469 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
471 free_turn(shooter_ptr);
473 /* project_length is already reset to 0 */
479 /* Take a (partial) turn */
480 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
481 shooter_ptr->is_fired = TRUE;
483 /* Sniper - Difficult to shot twice at 1 turn */
484 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
486 /* Sniper - Repeat shooting when double shots */
487 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
490 /* Start at the player */
494 object_copy(q_ptr, o_ptr);
499 vary_item(shooter_ptr, item, -1);
502 handle_stuff(shooter_ptr);
507 /* The shot does not hit yet */
510 /* Travel until stopped */
511 for (cur_dis = 0; cur_dis <= tdis; )
515 /* Hack -- Stop at the target */
516 if ((y == ty) && (x == tx)) break;
518 /* Calculate the new location (see "project()") */
521 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
524 if (snipe_type == SP_KILL_WALL)
526 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
528 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
530 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
531 /* Forget the wall */
532 g_ptr->info &= ~(CAVE_MARK);
533 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
535 /* Destroy the wall */
536 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
543 /* Stopped by walls/doors */
544 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;
546 /* Advance the distance */
550 if (snipe_type == SP_LITE)
552 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
553 note_spot(shooter_ptr, ny, nx);
554 lite_spot(shooter_ptr, ny, nx);
557 /* The player can see the (on screen) missile */
558 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
560 char c = object_char(q_ptr);
561 byte a = object_attr(q_ptr);
563 /* Draw, Hilite, Fresh, Pause, Erase */
564 print_rel(shooter_ptr, c, a, ny, nx);
565 move_cursor_relative(ny, nx);
567 Term_xtra(TERM_XTRA_DELAY, msec);
568 lite_spot(shooter_ptr, ny, nx);
572 /* The player cannot see the missile */
575 /* Pause anyway, for consistancy */
576 Term_xtra(TERM_XTRA_DELAY, msec);
580 if (snipe_type == SP_KILL_TRAP)
582 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
583 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
587 if (snipe_type == SP_EVILNESS)
589 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
590 note_spot(shooter_ptr, ny, nx);
591 lite_spot(shooter_ptr, ny, nx);
597 /* Save the new location */
601 /* Monster here, Try to hit it */
602 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
604 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
606 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
607 monster_race *r_ptr = &r_info[m_ptr->r_idx];
609 /* Check the visibility */
612 /* Note the collision */
615 if (MON_CSLEEP(m_ptr))
617 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
618 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
621 if ((r_ptr->level + 10) > shooter_ptr->lev)
623 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
624 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
627 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
628 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
629 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
630 else if (shooter_ptr->lev > 34) amount = 2;
631 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
632 shooter_ptr->update |= (PU_BONUS);
636 if (shooter_ptr->riding)
638 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
639 && ((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)
642 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
643 shooter_ptr->update |= (PU_BONUS);
647 /* Did we hit it (penalize range) */
648 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
651 int tdam = tdam_base;
653 /* Get extra damage from concentration */
654 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
656 /* Handle unseen monster */
659 /* Invisible monster */
660 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
663 /* Handle visible monster */
666 GAME_TEXT m_name[MAX_NLEN];
668 /* Get "the monster" or "it" */
669 monster_desc(shooter_ptr, m_name, m_ptr, 0);
671 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
675 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
676 health_track(shooter_ptr, c_mon_ptr->m_idx);
680 if (snipe_type == SP_NEEDLE)
682 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
683 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
685 GAME_TEXT m_name[MAX_NLEN];
687 /* Get "the monster" or "it" */
688 monster_desc(shooter_ptr, m_name, m_ptr, 0);
690 tdam = m_ptr->hp + 1;
691 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
697 /* Apply special damage */
698 tdam = tot_dam_aux_shot(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
699 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
701 /* No negative damage */
702 if (tdam < 0) tdam = 0;
704 /* Modify the damage */
705 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
708 msg_format_wizard(CHEAT_MONSTER,
709 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
710 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
713 if (snipe_type == SP_EXPLODE)
715 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
717 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
718 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
723 if (snipe_type == SP_HOLYNESS)
725 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
726 note_spot(shooter_ptr, ny, nx);
727 lite_spot(shooter_ptr, ny, nx);
730 /* Hit the monster, check for death */
731 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
740 if (object_is_fixed_artifact(q_ptr) &&
741 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
743 GAME_TEXT m_name[MAX_NLEN];
745 monster_desc(shooter_ptr, m_name, m_ptr, 0);
748 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
751 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
753 /* Anger the monster */
754 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
756 if (fear && m_ptr->ml)
758 GAME_TEXT m_name[MAX_NLEN];
760 monster_desc(shooter_ptr, m_name, m_ptr, 0);
761 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
764 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
767 if (snipe_type == SP_RUSH)
769 int n = randint1(5) + 3;
770 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
772 for (; cur_dis <= tdis; )
779 /* Calculate the new location (see "project()") */
780 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
782 /* Stopped by wilderness boundary */
783 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
785 /* Stopped by walls/doors */
786 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
788 /* Stopped by monsters */
789 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
791 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
792 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
797 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
799 lite_spot(shooter_ptr, ny, nx);
800 lite_spot(shooter_ptr, oy, ox);
803 Term_xtra(TERM_XTRA_DELAY, msec);
815 if (snipe_type == SP_PIERCE)
817 if (shooter_ptr->concent < 1) break;
818 shooter_ptr->concent--;
827 /* Chance of breakage (during attacks) */
828 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
832 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
833 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
834 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
838 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
839 if (object_is_fixed_artifact(q_ptr))
841 a_info[j_ptr->name1].cur_num = 0;
846 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
847 object_copy(o_ptr, q_ptr);
850 o_ptr->marked &= OM_TOUCHED;
852 /* Forget location */
853 o_ptr->iy = o_ptr->ix = 0;
855 /* Memorize monster */
856 o_ptr->held_m_idx = m_idx;
859 o_ptr->next_o_idx = m_ptr->hold_o_idx;
862 m_ptr->hold_o_idx = o_idx;
864 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
866 /* Drop (or break) near that location */
867 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
871 /* Drop (or break) near that location */
872 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
875 /* Sniper - Repeat shooting when double shots */
878 /* Sniper - Loose his/her concentration after any shot */
879 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
884 * @brief プレイヤーからモンスターへの射撃命中判定 /
885 * Determine if the player "hits" a monster (normal combat).
886 * @param chance 基本命中値
887 * @param m_ptr モンスターの構造体参照ポインタ
888 * @param vis 目標を視界に捕らえているならばTRUEを指定
889 * @param o_name メッセージ表示時のモンスター名
890 * @return 命中と判定された場合TRUEを返す
891 * @note Always miss 5%, always hit 5%, otherwise random.
893 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
897 monster_race *r_ptr = &r_info[m_ptr->r_idx];
899 /* Percentile dice */
902 /* Snipers with high-concentration reduce instant miss percentage.*/
903 k += shooter_ptr->concent;
905 /* Hack -- Instant miss or hit */
906 if (k <= 5) return FALSE;
907 if (k > 95) return TRUE;
909 if (shooter_ptr->pseikaku == SEIKAKU_NAMAKE)
910 if (one_in_(20)) return FALSE;
913 if (chance <= 0) return FALSE;
916 if (shooter_ptr->concent)
918 ac *= (8 - shooter_ptr->concent);
922 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
924 /* Invisible monsters are harder to hit */
925 if (!vis) chance = (chance + 1) / 2;
927 /* Power competes against armor */
928 if (randint0(chance) < (ac * 3 / 4))
930 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
932 GAME_TEXT m_name[MAX_NLEN];
933 monster_desc(shooter_ptr, m_name, m_ptr, 0);
934 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
947 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
948 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
949 * @param weight 矢弾の重量
950 * @param plus_ammo 矢弾の命中修正
951 * @param plus_bow 弓の命中修正
952 * @param dam 現在算出中のダメージ値
953 * @return クリティカル修正が入ったダメージ値
955 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
958 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
960 /* Extract "shot" power */
961 i = shooter_ptr->to_h_b + plus_ammo;
963 if (shooter_ptr->tval_ammo == TV_BOLT)
964 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
966 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
969 /* Snipers can shot more critically with crossbows */
970 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
971 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
973 /* Good bow makes more critical */
974 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
977 if (randint1(10000) <= i)
979 k = weight * randint1(500);
983 msg_print(_("手ごたえがあった!", "It was a good hit!"));
988 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
993 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1005 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1006 * @param sval 射撃武器のアイテム副分類ID
1007 * @return 消費する基本エネルギー
1009 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1011 ENERGY energy = 10000;
1013 /* Analyze the launcher */
1016 /* Sling and ammo */
1023 /* Short Bow and Arrow */
1030 /* Long Bow and Arrow */
1037 /* Bow of irresponsiblity and Arrow */
1044 /* Light Crossbow and Bolt */
1051 /* Heavy Crossbow and Bolt */
1066 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1070 /* Analyze the launcher */
1073 /* Sling and ammo */
1080 /* Short Bow and Arrow */
1087 /* Long Bow and Arrow */
1094 /* Bow of irresponsiblity and Arrow */
1101 /* Light Crossbow and Bolt */
1108 /* Heavy Crossbow and Bolt */
1121 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1122 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1123 * @param plus_ammo 矢弾のダメージ修正
1124 * @param plus_bow 弓のダメージ修正
1126 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1128 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1131 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1133 /* Extract "shot" power */
1134 i = shooter_ptr->to_h_b + plus_ammo;
1136 if (shooter_ptr->tval_ammo == TV_BOLT)
1137 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1139 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1141 /* Snipers can shot more critically with crossbows */
1142 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1143 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1145 /* Good bow makes more critical */
1146 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1154 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1155 * @param weight 武器の重量
1156 * @param plus_ammo 矢弾のダメージ修正
1157 * @param plus_bow 弓のダメージ修正
1158 * @param dam 基本ダメージ量
1161 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1165 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1170 crit = MIN(500, 900 / weight);
1171 num += dam * 3 / 2 * crit;
1174 crit = MIN(500, 1350 / weight);
1176 num += dam * 2 * crit;
1182 num += dam * 3 * crit;
1188 num += (10000 - i) * dam;
1195 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1196 * @param shooter_ptr プレーヤーへの参照ポインタ
1197 * @param weight 武器の重量
1198 * @param plus 武器のダメージ修正
1200 * @param meichuu 命中値
1201 * @param dokubari 毒針処理か否か
1204 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1207 if (dokubari) return dam;
1209 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1215 if (k < 400) num += (2 * dam + 5) * (400 - k);
1216 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1217 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1218 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1219 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1222 if (shooter_ptr->pclass == CLASS_NINJA)
1225 num += (4444 - i) * dam;
1231 num += (5000 - i) * dam;