1 #include "system/angband.h"
2 #include "core/stuff-handler.h"
4 #include "main/sound-definitions-table.h"
7 #include "monster/monster.h"
8 #include "monster/monster-status.h"
9 #include "spell/monster-spell.h"
10 #include "object/artifact.h"
12 #include "player/player-status.h"
13 #include "player/player-skill.h"
14 #include "player/player-class.h"
15 #include "player/player-personality.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"
24 #include "view/display-main-window.h"
25 #include "object/object-kind.h"
26 #include "targeting.h"
27 #include "effect/spells-effect-util.h"
28 #include "spell/process-effect.h"
31 * @brief 矢弾を射撃した際のスレイ倍率をかけた結果を返す /
32 * Determines the odds of an object breaking when thrown at a monster
33 * @param o_ptr 矢弾のオブジェクト構造体参照ポインタ
34 * @param tdam 計算途中のダメージ量
35 * @param m_ptr 目標モンスターの構造体参照ポインタ
36 * @return スレイ倍率をかけたダメージ量
38 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)
42 monster_race *r_ptr = &r_info[m_ptr->r_idx];
44 BIT_FLAGS flgs[TR_FLAG_SIZE];
45 object_flags(o_ptr, flgs);
47 /* Some "weapons" and "ammo" do extra damage */
54 if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
56 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
58 r_ptr->r_flags3 |= RF3_ANIMAL;
60 if (mult < 17) mult = 17;
63 if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL))
65 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
67 r_ptr->r_flags3 |= RF3_ANIMAL;
69 if (mult < 27) mult = 27;
72 if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
74 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
76 r_ptr->r_flags3 |= RF3_EVIL;
78 if (mult < 15) mult = 15;
81 if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL))
83 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
85 r_ptr->r_flags3 |= RF3_EVIL;
87 if (mult < 25) mult = 25;
90 if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
92 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
94 r_ptr->r_flags2 |= RF2_HUMAN;
96 if (mult < 17) mult = 17;
99 if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN))
101 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
103 r_ptr->r_flags2 |= RF2_HUMAN;
105 if (mult < 27) mult = 27;
108 if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
110 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
112 r_ptr->r_flags3 |= RF3_UNDEAD;
114 if (mult < 20) mult = 20;
117 if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD))
119 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
121 r_ptr->r_flags3 |= RF3_UNDEAD;
123 if (mult < 30) mult = 30;
126 if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
128 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
130 r_ptr->r_flags3 |= RF3_DEMON;
132 if (mult < 20) mult = 20;
135 if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON))
137 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
139 r_ptr->r_flags3 |= RF3_DEMON;
141 if (mult < 30) mult = 30;
144 if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC))
146 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
148 r_ptr->r_flags3 |= RF3_ORC;
150 if (mult < 20) mult = 20;
153 if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC))
155 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
157 r_ptr->r_flags3 |= RF3_ORC;
159 if (mult < 30) mult = 30;
162 if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
164 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
166 r_ptr->r_flags3 |= RF3_TROLL;
169 if (mult < 20) mult = 20;
172 if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL))
174 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
176 r_ptr->r_flags3 |= RF3_TROLL;
178 if (mult < 30) mult = 30;
181 if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
183 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
185 r_ptr->r_flags3 |= RF3_GIANT;
187 if (mult < 20) mult = 20;
190 if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT))
192 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
194 r_ptr->r_flags3 |= RF3_GIANT;
196 if (mult < 30) mult = 30;
199 if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
201 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
203 r_ptr->r_flags3 |= RF3_DRAGON;
205 if (mult < 20) mult = 20;
208 if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON))
210 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
212 r_ptr->r_flags3 |= RF3_DRAGON;
214 if (mult < 30) mult = 30;
215 if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) &&
216 (sniper_ptr->inventory_list[INVEN_BOW].name1 == ART_BARD))
220 if (have_flag(flgs, TR_BRAND_ACID))
222 /* Notice immunity */
223 if (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK)
225 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
227 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK);
232 if (mult < 17) mult = 17;
236 if (have_flag(flgs, TR_BRAND_ELEC))
238 /* Notice immunity */
239 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
241 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
243 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
248 if (mult < 17) mult = 17;
252 if (have_flag(flgs, TR_BRAND_FIRE))
254 /* Notice immunity */
255 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
257 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
259 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
262 /* Otherwise, take the damage */
265 if (r_ptr->flags3 & RF3_HURT_FIRE)
267 if (mult < 25) mult = 25;
268 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
270 r_ptr->r_flags3 |= RF3_HURT_FIRE;
273 else if (mult < 17) mult = 17;
277 if (have_flag(flgs, TR_BRAND_COLD))
279 /* Notice immunity */
280 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
282 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
284 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
287 /* Otherwise, take the damage */
290 if (r_ptr->flags3 & RF3_HURT_COLD)
292 if (mult < 25) mult = 25;
293 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
295 r_ptr->r_flags3 |= RF3_HURT_COLD;
298 else if (mult < 17) mult = 17;
302 if (have_flag(flgs, TR_BRAND_POIS))
304 /* Notice immunity */
305 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
307 if (is_original_ap_and_seen(sniper_ptr, m_ptr))
309 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
312 /* Otherwise, take the damage */
315 if (mult < 17) mult = 17;
319 if ((have_flag(flgs, TR_FORCE_WEAPON)) && (sniper_ptr->csp > (sniper_ptr->msp / 30)))
321 sniper_ptr->csp -= (1 + (sniper_ptr->msp / 30));
322 sniper_ptr->redraw |= (PR_MANA);
330 if (snipe_type) mult = tot_dam_aux_snipe(sniper_ptr, mult, m_ptr, snipe_type);
332 /* Return the total damage */
333 return (tdam * mult / 10);
339 * Fire an object from the pack or floor.
340 * @param item 射撃するオブジェクトの所持ID
341 * @param j_ptr 射撃武器のオブジェクト参照ポインタ
345 * You may only fire items that "match" your missile launcher.
346 * You must use slings + pebbles/shots, bows + arrows, xbows + bolts.
347 * See "calc_bonuses()" for more calculations and such.
348 * Note that "firing" a missile is MUCH better than "throwing" it.
349 * Note: "unseen" monsters are very hard to hit.
350 * Objects are more likely to break if they "attempt" to hit a monster.
351 * Rangers (with Bows) and Anyone (with "Extra Shots") get extra shots.
352 * The "extra shot" code works by decreasing the amount of energy
353 * required to make each shot, spreading the shots out over time.
354 * Note that when firing missiles, the launcher multiplier is applied
355 * after all the bonuses are added in, making multipliers very useful.
356 * Note that Bows of "Extra Might" get extra range and an extra bonus
357 * for the damage multiplier.
358 * Note that Bows of "Extra Shots" give an extra shot.
361 void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
365 POSITION y, x, ny, nx, ty, tx, prev_y, prev_x;
366 int tdam_base, tdis, thits, tmul;
368 int cur_dis, visible;
376 bool hit_body = FALSE;
378 GAME_TEXT o_name[MAX_NLEN];
380 u16b path_g[512]; /* For calcuration of path length */
382 int msec = delay_factor * delay_factor * delay_factor;
385 bool stick_to = FALSE;
387 /* Access the item (if in the pack) */
390 o_ptr = &shooter_ptr->inventory_list[item];
394 o_ptr = &shooter_ptr->current_floor_ptr->o_list[0 - item];
397 /* Sniper - Cannot shot a single arrow twice */
398 if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE;
400 object_desc(shooter_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
402 /* Use the proper number of shots */
403 thits = shooter_ptr->num_fire;
405 /* Use a base distance */
408 /* Base damage from thrown object plus launcher bonus */
409 tdam_base = damroll(o_ptr->dd, o_ptr->ds) + o_ptr->to_d + j_ptr->to_d;
411 /* Actually "fire" the object */
412 bonus = (shooter_ptr->to_h_b + o_ptr->to_h + j_ptr->to_h);
413 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
414 chance = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + bonus) * BTH_PLUS_ADJ);
416 chance = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + bonus) * BTH_PLUS_ADJ);
418 shooter_ptr->energy_use = bow_energy(j_ptr->sval);
419 tmul = bow_tmul(j_ptr->sval);
421 /* Get extra "power" from "extra might" */
422 if (shooter_ptr->xtra_might) tmul++;
424 tmul = tmul * (100 + (int)(adj_str_td[shooter_ptr->stat_ind[A_STR]]) - 128);
426 /* Boost the damage */
431 tdis = 13 + tmul / 80;
432 if ((j_ptr->sval == SV_LIGHT_XBOW) || (j_ptr->sval == SV_HEAVY_XBOW))
434 if (shooter_ptr->concent)
435 tdis -= (5 - (shooter_ptr->concent + 1) / 2);
440 project_length = tdis + 1;
442 /* Get a direction (or cancel) */
443 if (!get_aim_dir(shooter_ptr, &dir))
445 free_turn(shooter_ptr);
447 if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
449 /* need not to reset project_length (already did)*/
454 /* Predict the "target" location */
455 tx = shooter_ptr->x + 99 * ddx[dir];
456 ty = shooter_ptr->y + 99 * ddy[dir];
458 /* Check for "target request" */
459 if ((dir == 5) && target_okay(shooter_ptr))
465 /* Get projection path length */
466 tdis = project_path(shooter_ptr, path_g, project_length, shooter_ptr->y, shooter_ptr->x, ty, tx, PROJECT_PATH | PROJECT_THRU) - 1;
468 project_length = 0; /* reset to default */
470 /* Don't shoot at my feet */
471 if (tx == shooter_ptr->x && ty == shooter_ptr->y)
473 free_turn(shooter_ptr);
475 /* project_length is already reset to 0 */
481 /* Take a (partial) turn */
482 shooter_ptr->energy_use = (shooter_ptr->energy_use / thits);
483 shooter_ptr->is_fired = TRUE;
485 /* Sniper - Difficult to shot twice at 1 turn */
486 if (snipe_type == SP_DOUBLE) shooter_ptr->concent = (shooter_ptr->concent + 1) / 2;
488 /* Sniper - Repeat shooting when double shots */
489 for (i = 0; i < ((snipe_type == SP_DOUBLE) ? 2 : 1); i++)
492 /* Start at the player */
496 object_copy(q_ptr, o_ptr);
501 vary_item(shooter_ptr, item, -1);
504 handle_stuff(shooter_ptr);
509 /* The shot does not hit yet */
512 /* Travel until stopped */
513 for (cur_dis = 0; cur_dis <= tdis; )
517 /* Hack -- Stop at the target */
518 if ((y == ty) && (x == tx)) break;
520 /* Calculate the new location (see "project()") */
523 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
526 if (snipe_type == SP_KILL_WALL)
528 g_ptr = &shooter_ptr->current_floor_ptr->grid_array[ny][nx];
530 if (cave_have_flag_grid(g_ptr, FF_HURT_ROCK) && !g_ptr->m_idx)
532 if (g_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
533 /* Forget the wall */
534 g_ptr->info &= ~(CAVE_MARK);
535 shooter_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
537 /* Destroy the wall */
538 cave_alter_feat(shooter_ptr, ny, nx, FF_HURT_ROCK);
545 /* Stopped by walls/doors */
546 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;
548 /* Advance the distance */
552 if (snipe_type == SP_LITE)
554 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
555 note_spot(shooter_ptr, ny, nx);
556 lite_spot(shooter_ptr, ny, nx);
559 /* The player can see the (on screen) missile */
560 if (panel_contains(ny, nx) && player_can_see_bold(shooter_ptr, ny, nx))
562 char c = object_char(q_ptr);
563 byte a = object_attr(q_ptr);
565 /* Draw, Hilite, Fresh, Pause, Erase */
566 print_rel(shooter_ptr, c, a, ny, nx);
567 move_cursor_relative(ny, nx);
569 Term_xtra(TERM_XTRA_DELAY, msec);
570 lite_spot(shooter_ptr, ny, nx);
574 /* The player cannot see the missile */
577 /* Pause anyway, for consistancy */
578 Term_xtra(TERM_XTRA_DELAY, msec);
582 if (snipe_type == SP_KILL_TRAP)
584 project(shooter_ptr, 0, 0, ny, nx, 0, GF_KILL_TRAP,
585 (PROJECT_JUMP | PROJECT_HIDE | PROJECT_GRID | PROJECT_ITEM), -1);
589 if (snipe_type == SP_EVILNESS)
591 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
592 note_spot(shooter_ptr, ny, nx);
593 lite_spot(shooter_ptr, ny, nx);
599 /* Save the new location */
603 /* Monster here, Try to hit it */
604 if (shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx)
606 grid_type *c_mon_ptr = &shooter_ptr->current_floor_ptr->grid_array[y][x];
608 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[c_mon_ptr->m_idx];
609 monster_race *r_ptr = &r_info[m_ptr->r_idx];
611 /* Check the visibility */
614 /* Note the collision */
617 if (MON_CSLEEP(m_ptr))
619 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_COMPASSION, -1);
620 if (!(r_ptr->flags3 & RF3_EVIL) || one_in_(5)) chg_virtue(shooter_ptr, V_HONOUR, -1);
623 if ((r_ptr->level + 10) > shooter_ptr->lev)
625 int now_exp = shooter_ptr->weapon_exp[0][j_ptr->sval];
626 if (now_exp < s_info[shooter_ptr->pclass].w_max[0][j_ptr->sval])
629 if (now_exp < WEAPON_EXP_BEGINNER) amount = 80;
630 else if (now_exp < WEAPON_EXP_SKILLED) amount = 25;
631 else if ((now_exp < WEAPON_EXP_EXPERT) && (shooter_ptr->lev > 19)) amount = 10;
632 else if (shooter_ptr->lev > 34) amount = 2;
633 shooter_ptr->weapon_exp[0][j_ptr->sval] += amount;
634 shooter_ptr->update |= (PU_BONUS);
638 if (shooter_ptr->riding)
640 if ((shooter_ptr->skill_exp[GINOU_RIDING] < s_info[shooter_ptr->pclass].s_max[GINOU_RIDING])
641 && ((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)
644 shooter_ptr->skill_exp[GINOU_RIDING] += 1;
645 shooter_ptr->update |= (PU_BONUS);
649 /* Did we hit it (penalize range) */
650 if (test_hit_fire(shooter_ptr, chance - cur_dis, m_ptr, m_ptr->ml, o_name))
653 int tdam = tdam_base;
655 /* Get extra damage from concentration */
656 if (shooter_ptr->concent) tdam = boost_concentration_damage(shooter_ptr, tdam);
658 /* Handle unseen monster */
661 /* Invisible monster */
662 msg_format(_("%sが敵を捕捉した。", "The %s finds a mark."), o_name);
665 /* Handle visible monster */
668 GAME_TEXT m_name[MAX_NLEN];
670 /* Get "the monster" or "it" */
671 monster_desc(shooter_ptr, m_name, m_ptr, 0);
673 msg_format(_("%sが%sに命中した。", "The %s hits %s."), o_name, m_name);
677 if (!shooter_ptr->image) monster_race_track(shooter_ptr, m_ptr->ap_r_idx);
678 health_track(shooter_ptr, c_mon_ptr->m_idx);
682 if (snipe_type == SP_NEEDLE)
684 if ((randint1(randint1(r_ptr->level / (3 + shooter_ptr->concent)) + (8 - shooter_ptr->concent)) == 1)
685 && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2))
687 GAME_TEXT m_name[MAX_NLEN];
689 /* Get "the monster" or "it" */
690 monster_desc(shooter_ptr, m_name, m_ptr, 0);
692 tdam = m_ptr->hp + 1;
693 msg_format(_("%sの急所に突き刺さった!", "Your shot hit a fatal spot of %s!"), m_name);
699 /* Apply special damage */
700 tdam = tot_dam_aux_shot(shooter_ptr, q_ptr, tdam, m_ptr, snipe_type);
701 tdam = critical_shot(shooter_ptr, q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
703 /* No negative damage */
704 if (tdam < 0) tdam = 0;
706 /* Modify the damage */
707 tdam = mon_damage_mod(shooter_ptr, m_ptr, tdam, FALSE);
710 msg_format_wizard(CHEAT_MONSTER,
711 _("%dのダメージを与えた。(残りHP %d/%d(%d))", "You do %d damage. (left HP %d/%d(%d))"),
712 tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp);
715 if (snipe_type == SP_EXPLODE)
717 u16b flg = (PROJECT_STOP | PROJECT_JUMP | PROJECT_KILL | PROJECT_GRID);
719 sound(SOUND_EXPLODE); /* No explode sound - use breath fire instead */
720 project(shooter_ptr, 0, ((shooter_ptr->concent + 1) / 2 + 1), ny, nx, tdam, GF_MISSILE, flg, -1);
725 if (snipe_type == SP_HOLYNESS)
727 shooter_ptr->current_floor_ptr->grid_array[ny][nx].info |= (CAVE_GLOW);
728 note_spot(shooter_ptr, ny, nx);
729 lite_spot(shooter_ptr, ny, nx);
732 /* Hit the monster, check for death */
733 if (mon_take_hit(shooter_ptr, c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr))))
742 if (object_is_fixed_artifact(q_ptr) &&
743 (shooter_ptr->pclass != CLASS_SNIPER || shooter_ptr->concent == 0))
745 GAME_TEXT m_name[MAX_NLEN];
747 monster_desc(shooter_ptr, m_name, m_ptr, 0);
750 msg_format(_("%sは%sに突き刺さった!", "%^s is stuck in %s!"), o_name, m_name);
753 message_pain(shooter_ptr, c_mon_ptr->m_idx, tdam);
755 /* Anger the monster */
756 if (tdam > 0) anger_monster(shooter_ptr, m_ptr);
758 if (fear && m_ptr->ml)
760 GAME_TEXT m_name[MAX_NLEN];
762 monster_desc(shooter_ptr, m_name, m_ptr, 0);
763 msg_format(_("%^sは恐怖して逃げ出した!", "%^s flees in terror!"), m_name);
766 set_target(m_ptr, shooter_ptr->y, shooter_ptr->x);
769 if (snipe_type == SP_RUSH)
771 int n = randint1(5) + 3;
772 MONSTER_IDX m_idx = c_mon_ptr->m_idx;
774 for (; cur_dis <= tdis; )
781 /* Calculate the new location (see "project()") */
782 mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx);
784 /* Stopped by wilderness boundary */
785 if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break;
787 /* Stopped by walls/doors */
788 if (!player_can_enter(shooter_ptr, shooter_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break;
790 /* Stopped by monsters */
791 if (!is_cave_empty_bold(shooter_ptr, ny, nx)) break;
793 shooter_ptr->current_floor_ptr->grid_array[ny][nx].m_idx = m_idx;
794 shooter_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = 0;
799 update_monster(shooter_ptr, c_mon_ptr->m_idx, TRUE);
801 lite_spot(shooter_ptr, ny, nx);
802 lite_spot(shooter_ptr, oy, ox);
805 Term_xtra(TERM_XTRA_DELAY, msec);
817 if (snipe_type == SP_PIERCE)
819 if (shooter_ptr->concent < 1) break;
820 shooter_ptr->concent--;
829 /* Chance of breakage (during attacks) */
830 j = (hit_body ? breakage_chance(shooter_ptr, q_ptr, shooter_ptr->pclass == CLASS_ARCHER, snipe_type) : 0);
834 MONSTER_IDX m_idx = shooter_ptr->current_floor_ptr->grid_array[y][x].m_idx;
835 monster_type *m_ptr = &shooter_ptr->current_floor_ptr->m_list[m_idx];
836 OBJECT_IDX o_idx = o_pop(shooter_ptr->current_floor_ptr);
840 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), o_name);
841 if (object_is_fixed_artifact(q_ptr))
843 a_info[j_ptr->name1].cur_num = 0;
848 o_ptr = &shooter_ptr->current_floor_ptr->o_list[o_idx];
849 object_copy(o_ptr, q_ptr);
852 o_ptr->marked &= OM_TOUCHED;
854 /* Forget location */
855 o_ptr->iy = o_ptr->ix = 0;
857 /* Memorize monster */
858 o_ptr->held_m_idx = m_idx;
861 o_ptr->next_o_idx = m_ptr->hold_o_idx;
864 m_ptr->hold_o_idx = o_idx;
866 else if (cave_have_flag_bold(shooter_ptr->current_floor_ptr, y, x, FF_PROJECT))
868 /* Drop (or break) near that location */
869 (void)drop_near(shooter_ptr, q_ptr, j, y, x);
873 /* Drop (or break) near that location */
874 (void)drop_near(shooter_ptr, q_ptr, j, prev_y, prev_x);
877 /* Sniper - Repeat shooting when double shots */
880 /* Sniper - Loose his/her concentration after any shot */
881 if (shooter_ptr->concent) reset_concentration(shooter_ptr, FALSE);
886 * @brief プレイヤーからモンスターへの射撃命中判定 /
887 * Determine if the player "hits" a monster (normal combat).
888 * @param chance 基本命中値
889 * @param m_ptr モンスターの構造体参照ポインタ
890 * @param vis 目標を視界に捕らえているならばTRUEを指定
891 * @param o_name メッセージ表示時のモンスター名
892 * @return 命中と判定された場合TRUEを返す
893 * @note Always miss 5%, always hit 5%, otherwise random.
895 bool test_hit_fire(player_type *shooter_ptr, int chance, monster_type *m_ptr, int vis, char* o_name)
899 monster_race *r_ptr = &r_info[m_ptr->r_idx];
901 /* Percentile dice */
904 /* Snipers with high-concentration reduce instant miss percentage.*/
905 k += shooter_ptr->concent;
907 /* Hack -- Instant miss or hit */
908 if (k <= 5) return FALSE;
909 if (k > 95) return TRUE;
911 if (shooter_ptr->pseikaku == SEIKAKU_NAMAKE)
912 if (one_in_(20)) return FALSE;
915 if (chance <= 0) return FALSE;
918 if (shooter_ptr->concent)
920 ac *= (8 - shooter_ptr->concent);
924 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr)) ac *= 3;
926 /* Invisible monsters are harder to hit */
927 if (!vis) chance = (chance + 1) / 2;
929 /* Power competes against armor */
930 if (randint0(chance) < (ac * 3 / 4))
932 if (m_ptr->r_idx == MON_GOEMON && !MON_CSLEEP(m_ptr))
934 GAME_TEXT m_name[MAX_NLEN];
935 monster_desc(shooter_ptr, m_name, m_ptr, 0);
936 msg_format(_("%sは%sを斬り捨てた!", "%s cuts down %s!"), m_name, o_name);
949 * @brief プレイヤーからモンスターへの射撃クリティカル判定 /
950 * Critical hits (from objects thrown by player) Factor in item weight, total plusses, and player level.
951 * @param weight 矢弾の重量
952 * @param plus_ammo 矢弾の命中修正
953 * @param plus_bow 弓の命中修正
954 * @param dam 現在算出中のダメージ値
955 * @return クリティカル修正が入ったダメージ値
957 HIT_POINT critical_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
960 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
962 /* Extract "shot" power */
963 i = shooter_ptr->to_h_b + plus_ammo;
965 if (shooter_ptr->tval_ammo == TV_BOLT)
966 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
968 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
971 /* Snipers can shot more critically with crossbows */
972 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
973 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
975 /* Good bow makes more critical */
976 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
979 if (randint1(10000) <= i)
981 k = weight * randint1(500);
985 msg_print(_("手ごたえがあった!", "It was a good hit!"));
990 msg_print(_("かなりの手ごたえがあった!", "It was a great hit!"));
995 msg_print(_("会心の一撃だ!", "It was a superb hit!"));
1007 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
1008 * @param sval 射撃武器のアイテム副分類ID
1009 * @return 消費する基本エネルギー
1011 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
1013 ENERGY energy = 10000;
1015 /* Analyze the launcher */
1018 /* Sling and ammo */
1025 /* Short Bow and Arrow */
1032 /* Long Bow and Arrow */
1039 /* Bow of irresponsiblity and Arrow */
1046 /* Light Crossbow and Bolt */
1053 /* Heavy Crossbow and Bolt */
1068 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
1072 /* Analyze the launcher */
1075 /* Sling and ammo */
1082 /* Short Bow and Arrow */
1089 /* Long Bow and Arrow */
1096 /* Bow of irresponsiblity and Arrow */
1103 /* Light Crossbow and Bolt */
1110 /* Heavy Crossbow and Bolt */
1123 * @brief 射撃時クリティカルによるダメージ期待値修正計算(スナイパーの集中処理と武器経験値) / critical happens at i / 10000
1124 * @param shooter_ptr 射撃を行うクリーチャー参照ポインタ
1125 * @param plus_ammo 矢弾のダメージ修正
1126 * @param plus_bow 弓のダメージ修正
1128 * @note 基本ダメージ量と重量はこの部位では計算に加わらない。
1130 HIT_POINT calc_crit_ratio_shot(player_type* shooter_ptr, HIT_POINT plus_ammo, HIT_POINT plus_bow)
1133 object_type *j_ptr = &shooter_ptr->inventory_list[INVEN_BOW];
1135 /* Extract "shot" power */
1136 i = shooter_ptr->to_h_b + plus_ammo;
1138 if (shooter_ptr->tval_ammo == TV_BOLT)
1139 i = (shooter_ptr->skill_thb + (shooter_ptr->weapon_exp[0][j_ptr->sval] / 400 + i) * BTH_PLUS_ADJ);
1141 i = (shooter_ptr->skill_thb + ((shooter_ptr->weapon_exp[0][j_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200 + i) * BTH_PLUS_ADJ);
1143 /* Snipers can shot more critically with crossbows */
1144 if (shooter_ptr->concent) i += ((i * shooter_ptr->concent) / 5);
1145 if ((shooter_ptr->pclass == CLASS_SNIPER) && (shooter_ptr->tval_ammo == TV_BOLT)) i *= 2;
1147 /* Good bow makes more critical */
1148 i += plus_bow * 8 * (shooter_ptr->concent ? shooter_ptr->concent + 5 : 5);
1156 * @brief 射撃時クリティカルによるダメージ期待値修正計算(重量依存部分) / critical happens at i / 10000
1157 * @param weight 武器の重量
1158 * @param plus_ammo 矢弾のダメージ修正
1159 * @param plus_bow 弓のダメージ修正
1160 * @param dam 基本ダメージ量
1163 HIT_POINT calc_expect_crit_shot(player_type *shooter_ptr, WEIGHT weight, int plus_ammo, int plus_bow, HIT_POINT dam)
1167 i = calc_crit_ratio_shot(shooter_ptr, plus_ammo, plus_bow);
1172 crit = MIN(500, 900 / weight);
1173 num += dam * 3 / 2 * crit;
1176 crit = MIN(500, 1350 / weight);
1178 num += dam * 2 * crit;
1184 num += dam * 3 * crit;
1190 num += (10000 - i) * dam;
1197 * @brief 攻撃時クリティカルによるダメージ期待値修正計算(重量と毒針処理) / critical happens at i / 10000
1198 * @param shooter_ptr プレーヤーへの参照ポインタ
1199 * @param weight 武器の重量
1200 * @param plus 武器のダメージ修正
1202 * @param meichuu 命中値
1203 * @param dokubari 毒針処理か否か
1206 HIT_POINT calc_expect_crit(player_type *shooter_ptr, WEIGHT weight, int plus, HIT_POINT dam, s16b meichuu, bool dokubari)
1209 if (dokubari) return dam;
1211 int i = (weight + (meichuu * 3 + plus * 5) + shooter_ptr->skill_thn);
1217 if (k < 400) num += (2 * dam + 5) * (400 - k);
1218 if (k < 700) num += (2 * dam + 10) * (MIN(700, k + 650) - MAX(400, k));
1219 if (k > (700 - 650) && k < 900) num += (3 * dam + 15) * (MIN(900, k + 650) - MAX(700, k));
1220 if (k > (900 - 650) && k < 1300) num += (3 * dam + 20) * (MIN(1300, k + 650) - MAX(900, k));
1221 if (k > (1300 - 650)) num += (7 * dam / 2 + 25) * MIN(650, k - (1300 - 650));
1224 if (shooter_ptr->pclass == CLASS_NINJA)
1227 num += (4444 - i) * dam;
1233 num += (5000 - i) * dam;