1 #include "combat/shoot.h"
2 #include "art-definition/art-bow-types.h"
3 #include "mind/mind-sniper.h"
4 #include "core/stuff-handler.h"
5 #include "effect/effect-characteristics.h"
6 #include "effect/spells-effect-util.h"
7 #include "floor/floor-object.h"
9 #include "inventory/inventory-object.h"
10 #include "io/targeting.h"
11 #include "main/sound-definitions-table.h"
12 #include "mind/snipe-types.h"
13 #include "monster-race/race-flags-resistance.h"
14 #include "monster-race/race-flags1.h"
15 #include "monster-race/race-flags2.h"
16 #include "monster-race/race-flags3.h"
17 #include "monster-race/race-flags7.h"
18 #include "monster-race/race-indice-types.h"
19 #include "monster/monster-describer.h"
20 #include "monster/monster-death.h"
21 #include "monster/monster-status.h"
22 #include "monster/monster-info.h"
23 #include "monster/monster-move.h"
24 #include "monster/monster-update.h"
25 #include "mspell/monster-spell.h"
26 #include "object-enchant/artifact.h"
27 #include "object-enchant/tr-types.h"
28 #include "object/object-broken.h"
29 #include "object/object-flags.h"
30 #include "object/object-flavor.h"
31 #include "object/object-generator.h"
32 #include "object/object-hook.h"
33 #include "object/object-kind.h"
34 #include "object/object-mark-types.h"
35 #include "object/object-info.h"
36 #include "player/avatar.h"
37 #include "player/player-class.h"
38 #include "player/player-personalities-table.h"
39 #include "player/player-skill.h"
40 #include "player/player-status.h"
41 #include "spell/process-effect.h"
42 #include "spell/spells-type.h"
43 #include "sv-definition/sv-bow-types.h"
44 #include "util/util.h"
45 #include "view/display-main-window.h"
46 #include "world/world-object.h"
49 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
50 * Determines the odds of an object breaking when thrown at a monster
51 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
52 * @param tdam 計算途中のダメージ量
53 * @param m_ptr 目標モンスターの構造体参照ポインタ
54 * @return スレイ倍率をかけたダメージ量
56 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)
60 monster_race *r_ptr = &r_info[m_ptr->r_idx];
62 BIT_FLAGS flgs[TR_FLAG_SIZE];
63 object_flags(o_ptr, flgs);
65 /* Some "weapons" and "ammo" do extra damage */
72 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
74 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
76 r_ptr->r_flags3 |= RF3_ANIMAL;
78 if (mult < 17) mult = 17;
81 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
83 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
85 r_ptr->r_flags3 |= RF3_ANIMAL;
87 if (mult < 27) mult = 27;
90 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
92 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
94 r_ptr->r_flags3 |= RF3_EVIL;
96 if (mult < 15) mult = 15;
99 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
101 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
103 r_ptr->r_flags3 |= RF3_EVIL;
105 if (mult < 25) mult = 25;
108 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
110 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
112 r_ptr->r_flags2 |= RF2_HUMAN;
114 if (mult < 17) mult = 17;
117 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
119 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
121 r_ptr->r_flags2 |= RF2_HUMAN;
123 if (mult < 27) mult = 27;
126 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
128 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
130 r_ptr->r_flags3 |= RF3_UNDEAD;
132 if (mult < 20) mult = 20;
135 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
137 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
139 r_ptr->r_flags3 |= RF3_UNDEAD;
141 if (mult < 30) mult = 30;
144 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
146 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
148 r_ptr->r_flags3 |= RF3_DEMON;
150 if (mult < 20) mult = 20;
153 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
155 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
157 r_ptr->r_flags3 |= RF3_DEMON;
159 if (mult < 30) mult = 30;
162 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
164 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
166 r_ptr->r_flags3 |= RF3_ORC;
168 if (mult < 20) mult = 20;
171 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
173 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
175 r_ptr->r_flags3 |= RF3_ORC;
177 if (mult < 30) mult = 30;
180 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
182 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
184 r_ptr->r_flags3 |= RF3_TROLL;
187 if (mult < 20) mult = 20;
190 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
192 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
194 r_ptr->r_flags3 |= RF3_TROLL;
196 if (mult < 30) mult = 30;
199 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
201 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
203 r_ptr->r_flags3 |= RF3_GIANT;
205 if (mult < 20) mult = 20;
208 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
210 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
212 r_ptr->r_flags3 |= RF3_GIANT;
214 if (mult < 30) mult = 30;
217 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
219 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
221 r_ptr->r_flags3 |= RF3_DRAGON;
223 if (mult < 20) mult = 20;
226 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
228 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
230 r_ptr->r_flags3 |= RF3_DRAGON;
232 if (mult < 30) mult = 30;
233 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
234 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
238 if (have_flag(flgs, TR_BRAND_ACID))
240 /* Notice immunity */
241 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
243 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
245 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
250 if (mult < 17) mult = 17;
254 if (have_flag(flgs, TR_BRAND_ELEC))
256 /* Notice immunity */
257 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
259 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
261 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
266 if (mult < 17) mult = 17;
270 if (have_flag(flgs, TR_BRAND_FIRE))
272 /* Notice immunity */
273 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
275 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
277 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
280 /* Otherwise, take the damage */
283 if (r_ptr->flags3 & RF3_HURT_FIRE)
285 if (mult < 25) mult = 25;
286 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
288 r_ptr->r_flags3 |= RF3_HURT_FIRE;
291 else if (mult < 17) mult = 17;
295 if (have_flag(flgs, TR_BRAND_COLD))
297 /* Notice immunity */
298 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
300 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
302 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
305 /* Otherwise, take the damage */
308 if (r_ptr->flags3 & RF3_HURT_COLD)
310 if (mult < 25) mult = 25;
311 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
313 r_ptr->r_flags3 |= RF3_HURT_COLD;
316 else if (mult < 17) mult = 17;
320 if (have_flag(flgs, TR_BRAND_POIS))
322 /* Notice immunity */
323 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
325 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
327 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
330 /* Otherwise, take the damage */
333 if (mult < 17) mult = 17;
337 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
339 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
340 sniper_ptr->redraw |= (PR_MANA);
348 if (snipe_type) mult = calc_snipe_damage_with_slay(sniper_ptr, mult, m_ptr, snipe_type);
350 /* Return the total damage */
351 return (tdam * mult / 10);
357 * Fire an object from the pack or floor.
358 * @param item 射撃するオブジェクトの所持ID
359 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
363 * You may only fire items that "match" your missile launcher.
364 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
365 * See "calc_bonuses()" for more calculations and such.
366 * Note that "firing" a missile is MUCH better than "throwing" it.
367 * Note: "unseen" monsters are very hard to hit.
368 * Objects are more likely to break if they "attempt" to hit a monster.
369 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
370 * The "extra shot" code works by decreasing the amount of energy
371 * required to make each shot, spreading the shots out over time.
372 * Note that when firing missiles, the launcher multiplier is applied
373 * after all the bonuses are added in, making multipliers very useful.
374 * Note that Bows of "Extra Might" get extra range and an extra bonus
375 * for the damage multiplier.
376 * Note that Bows of "Extra Shots" give an extra shot.
379 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
383 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
384 int tdam_base, tdis, thits, tmul;
386 int cur_dis, visible;
394 bool hit_body = FALSE;
396 GAME_TEXT o_name[MAX_NLEN];
398 u16b path_g[512]; /* For calcuration of path length */
400 int msec = delay_factor * delay_factor * delay_factor;
403 bool stick_to = FALSE;
405 /* Access the item (if in the pack) */
408 o_ptr = &shooter_ptr->inventory_list[item];
412 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
415 /* Sniper - Cannot shot a single arrow twice */
416 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
418 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
420 /* Use the proper number of shots */
421 thits = shooter_ptr->num_fire;
423 /* Use a base distance */
426 /* Base damage from thrown object plus launcher bonus */
427 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
429 /* Actually "fire" the object */
430 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
431 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
432 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
434 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
436 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
437 tmul = bow_tmul(j_ptr->sval);
439 /* Get extra "power" from "extra might" */
440 if (shooter_ptr->xtra_might) tmul++;
442 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
444 /* Boost the damage */
449 tdis = 13 + tmul / 80;
450 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
452 if (shooter_ptr->concent)
453 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
458 project_length = tdis + 1;
460 /* Get a direction (or cancel) */
461 if (!get_aim_dir(shooter_ptr, &dir))
463 free_turn(shooter_ptr);
465 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
467 /* need not to reset project_length (already did)*/
472 /* Predict the "target" location */
473 tx = shooter_ptr->x + 99 * ddx[dir];
474 ty = shooter_ptr->y + 99 * ddy[dir];
476 /* Check for "target request" */
477 if ((dir == 5) && target_okay(shooter_ptr))
483 /* Get projection path length */
484 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
486 project_length = 0; /* reset to default */
488 /* Don't shoot at my feet */
489 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
491 free_turn(shooter_ptr);
493 /* project_length is already reset to 0 */
499 /* Take a (partial) turn */
500 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
501 shooter_ptr->is_fired = TRUE;
503 /* Sniper - Difficult to shot twice at 1 turn */
504 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
506 /* Sniper - Repeat shooting when double shots */
507 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
510 /* Start at the player */
514 object_copy(q_ptr, o_ptr);
519 vary_item(shooter_ptr, item, -1);
522 handle_stuff(shooter_ptr);
527 /* The shot does not hit yet */
530 /* Travel until stopped */
531 for (cur_dis = 0; cur_dis <= tdis; )
535 /* Hack -- Stop at the target */
536 if ((y == ty) && (x == tx)) break;
538 /* Calculate the new location (see "project()") */
541 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
544 if (snipe_type == SP_KILL_WALL)
546 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
548 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
550 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
551 /* Forget the wall */
552 g_ptr->info &= ~(CAVE_MARK);
553 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
555 /* Destroy the wall */
556 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
563 /* Stopped by walls/doors */
564 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;
566 /* Advance the distance */
570 if (snipe_type == SP_LITE)
572 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
573 note_spot(shooter_ptr, ny, nx);
574 lite_spot(shooter_ptr, ny, nx);
577 /* The player can see the (on screen) missile */
578 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
580 char c = object_char(q_ptr);
581 byte a = object_attr(q_ptr);
583 /* Draw, Hilite, Fresh, Pause, Erase */
584 print_rel(shooter_ptr, c, a, ny, nx);
585 move_cursor_relative(ny, nx);
587 Term_xtra(TERM_XTRA_DELAY, msec);
588 lite_spot(shooter_ptr, ny, nx);
592 /* The player cannot see the missile */
595 /* Pause anyway, for consistancy */
596 Term_xtra(TERM_XTRA_DELAY, msec);
600 if (snipe_type == SP_KILL_TRAP)
602 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
603 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
607 if (snipe_type == SP_EVILNESS)
609 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
610 note_spot(shooter_ptr, ny, nx);
611 lite_spot(shooter_ptr, ny, nx);
617 /* Save the new location */
621 /* Monster here, Try to hit it */
622 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
624 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
626 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
627 monster_race *r_ptr = &r_info[m_ptr->r_idx];
629 /* Check the visibility */
632 /* Note the collision */
635 if (monster_csleep_remaining(m_ptr))
637 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
638 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
641 if ((r_ptr->level + 10) > shooter_ptr->lev)
643 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
644 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
647 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
648 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
649 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
650 else if (shooter_ptr->lev > 34) amount = 2;
651 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
652 shooter_ptr->update |= (PU_BONUS);
656 if (shooter_ptr->riding)
658 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
659 && ((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)
662 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
663 shooter_ptr->update |= (PU_BONUS);
667 /* Did we hit it (penalize range) */
668 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
671 int tdam = tdam_base;
673 /* Get extra damage from concentration */
674 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
676 /* Handle unseen monster */
679 /* Invisible monster */
680 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
683 /* Handle visible monster */
686 GAME_TEXT m_name[MAX_NLEN];
688 /* Get "the monster" or "it" */
689 monster_desc(shooter_ptr, m_name, m_ptr, 0);
691 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
695 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
696 health_track(shooter_ptr, c_mon_ptr->m_idx);
700 if (snipe_type == SP_NEEDLE)
702 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
703 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
705 GAME_TEXT m_name[MAX_NLEN];
707 /* Get "the monster" or "it" */
708 monster_desc(shooter_ptr, m_name, m_ptr, 0);
710 tdam = m_ptr->hp + 1;
711 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
717 /* Apply special damage */
718 tdam = calc_shot_damage_with_slay(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
719 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
721 /* No negative damage */
722 if (tdam < 0) tdam = 0;
724 /* Modify the damage */
725 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
728 msg_format_wizard(CHEAT_MONSTER,
729 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
730 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
733 if (snipe_type == SP_EXPLODE)
735 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
737 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
738 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
743 if (snipe_type == SP_HOLYNESS)
745 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
746 note_spot(shooter_ptr, ny, nx);
747 lite_spot(shooter_ptr, ny, nx);
750 /* Hit the monster, check for death */
751 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
760 if (object_is_fixed_artifact(q_ptr) &&
761 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
763 GAME_TEXT m_name[MAX_NLEN];
765 monster_desc(shooter_ptr, m_name, m_ptr, 0);
768 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
771 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
773 /* Anger the monster */
774 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
776 if (fear && m_ptr->ml)
778 GAME_TEXT m_name[MAX_NLEN];
780 monster_desc(shooter_ptr, m_name, m_ptr, 0);
781 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
784 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
787 if (snipe_type == SP_RUSH)
789 int n = randint1(5) + 3;
790 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
792 for (; cur_dis <= tdis; )
799 /* Calculate the new location (see "project()") */
800 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
802 /* Stopped by wilderness boundary */
803 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
805 /* Stopped by walls/doors */
806 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
808 /* Stopped by monsters */
809 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
811 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
812 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
817 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
819 lite_spot(shooter_ptr, ny, nx);
820 lite_spot(shooter_ptr, oy, ox);
823 Term_xtra(TERM_XTRA_DELAY, msec);
835 if (snipe_type == SP_PIERCE)
837 if (shooter_ptr->concent < 1) break;
838 shooter_ptr->concent--;
847 /* Chance of breakage (during attacks) */
848 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
852 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
853 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
854 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
858 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
859 if (object_is_fixed_artifact(q_ptr))
861 a_info[j_ptr->name1].cur_num = 0;
866 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
867 object_copy(o_ptr, q_ptr);
870 o_ptr->marked &= OM_TOUCHED;
872 /* Forget location */
873 o_ptr->iy = o_ptr->ix = 0;
875 /* Memorize monster */
876 o_ptr->held_m_idx = m_idx;
879 o_ptr->next_o_idx = m_ptr->hold_o_idx;
882 m_ptr->hold_o_idx = o_idx;
884 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
886 /* Drop (or break) near that location */
887 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
891 /* Drop (or break) near that location */
892 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
895 /* Sniper - Repeat shooting when double shots */
898 /* Sniper - Loose his/her concentration after any shot */
899 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
904 * @brief プレイヤーからモンスターへの射撃命中判定 /
905 * Determine if the player "hits" a monster (normal combat).
906 * @param chance 基本命中値
907 * @param m_ptr モンスターの構造体参照ポインタ
908 * @param vis 目標を視界に捕らえているならばTRUEを指定
909 * @param o_name メッセージ表示時のモンスター名
910 * @return 命中と判定された場合TRUEを返す
911 * @note Always miss 5%, always hit 5%, otherwise random.
913 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
917 monster_race *r_ptr = &r_info[m_ptr->r_idx];
919 /* Percentile dice */
922 /* Snipers with high-concentration reduce instant miss percentage.*/
923 k += shooter_ptr->concent;
925 /* Hack -- Instant miss or hit */
926 if (k <= 5) return FALSE;
927 if (k > 95) return TRUE;
929 if (shooter_ptr->pseikaku == PERSONALITY_LAZY)
930 if (one_in_(20)) return FALSE;
933 if (chance <= 0) return FALSE;
936 if (shooter_ptr->concent)
938 ac *= (8 - shooter_ptr->concent);
942 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr)) ac *= 3;
944 /* Invisible monsters are harder to hit */
945 if (!vis) chance = (chance + 1) / 2;
947 /* Power competes against armor */
948 if (randint0(chance) < (ac * 3 / 4))
950 if (m_ptr->r_idx == MON_GOEMON && !monster_csleep_remaining(m_ptr))
952 GAME_TEXT m_name[MAX_NLEN];
953 monster_desc(shooter_ptr, m_name, m_ptr, 0);
954 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
967 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
968 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
969 * @param weight 矢弾の重量
970 * @param plus_ammo 矢弾の命中修正
971 * @param plus_bow 弓の命中修正
972 * @param dam 現在算出中のダメージ値
973 * @return クリティカル修正が入ったダメージ値
975 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
978 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
980 /* Extract "shot" power */
981 i = shooter_ptr->to_h_b + plus_ammo;
983 if (shooter_ptr->tval_ammo == TV_BOLT)
984 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
986 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
989 /* Snipers can shot more critically with crossbows */
990 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
991 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
993 /* Good bow makes more critical */
994 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
997 if (randint1(10000) <= i)
999 k = weight * randint1(500);
1003 msg_print(_("手ごたえがあった!", "It was a good hit!"));
1008 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
1013 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1025 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1026 * @param sval 射撃武器のアイテム副分類ID
1027 * @return 消費する基本エネルギー
1029 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1031 ENERGY energy = 10000;
1033 /* Analyze the launcher */
1036 /* Sling and ammo */
1043 /* Short Bow and Arrow */
1050 /* Long Bow and Arrow */
1057 /* Bow of irresponsiblity and Arrow */
1064 /* Light Crossbow and Bolt */
1071 /* Heavy Crossbow and Bolt */
1086 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1090 /* Analyze the launcher */
1093 /* Sling and ammo */
1100 /* Short Bow and Arrow */
1107 /* Long Bow and Arrow */
1114 /* Bow of irresponsiblity and Arrow */
1121 /* Light Crossbow and Bolt */
1128 /* Heavy Crossbow and Bolt */
1141 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1142 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1143 * @param plus_ammo 矢弾のダメージ修正
1144 * @param plus_bow 弓のダメージ修正
1146 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1148 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1151 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1153 /* Extract "shot" power */
1154 i = shooter_ptr->to_h_b + plus_ammo;
1156 if (shooter_ptr->tval_ammo == TV_BOLT)
1157 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1159 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1161 /* Snipers can shot more critically with crossbows */
1162 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1163 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1165 /* Good bow makes more critical */
1166 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1174 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1175 * @param weight 武器の重量
1176 * @param plus_ammo 矢弾のダメージ修正
1177 * @param plus_bow 弓のダメージ修正
1178 * @param dam 基本ダメージ量
1181 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1185 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1190 crit = MIN(500, 900 / weight);
1191 num += dam * 3 / 2 * crit;
1194 crit = MIN(500, 1350 / weight);
1196 num += dam * 2 * crit;
1202 num += dam * 3 * crit;
1208 num += (10000 - i) * dam;
1215 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1216 * @param shooter_ptr プレーヤーへの参照ポインタ
1217 * @param weight 武器の重量
1218 * @param plus 武器のダメージ修正
1220 * @param meichuu 命中値
1221 * @param dokubari 毒針処理か否か
1224 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1227 if (dokubari) return dam;
1229 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1235 if (k < 400) num += (2 * dam + 5) * (400 - k);
1236 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1237 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1238 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1239 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1242 if (shooter_ptr->pclass == CLASS_NINJA)
1245 num += (4444 - i) * dam;
1251 num += (5000 - i) * dam;